Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
bash-first [2018/02/26 04:05]
telatina [The shell prompt]
bash-first [2020/02/07 09:51] (current)
Line 1: Line 1:
 +
 ====== Command Line: First tour ====== ====== Command Line: First tour ======
 +
 +  * Today'​s [[https://​www.slideshare.net/​procionesapiente/​first-adventure-within-a-shell-andrea-telatin-at-quadram-institute|Slideshow]]
 +Our main goal is to set up everyone clients, and to get the main tools to work in the future sessions: ability to connect to the remote server, using ''​screen''​ to keep a living session on the remote server.
 +
 ===== General rules ===== ===== General rules =====
   * :!: Read carefully each paragraph before typing commands.   * :!: Read carefully each paragraph before typing commands.
Line 30: Line 35:
 <code bash> <code bash>
 ls ls
 +</​code>​
 +
 +We can also add a first //switch// to this command: to view more details use the ''​-l''​ (//long//) switch:
 +<code bash>
 +ls -l
 </​code>​ </​code>​
  
Line 44: Line 54:
  
 Remember that you have to wait to see the shell prompt before issuing new commands. If you don't see it, maybe the previous command is stuck or simply still working. Remember that you have to wait to see the shell prompt before issuing new commands. If you don't see it, maybe the previous command is stuck or simply still working.
 +
 +===== Using a demo "​program"​ =====
 +Type the command:
 +<code bash>
 +weather.pl
 +</​code>​
 +
 +Many programs will give you a short help message using the switches ''​-h''​ or ''​--help''​. Try with one of these, then get the weather for Cambridge.
 +
 +===== Using screen =====
 +Before moving on with the workshop, we will start using a powerful program for a safer and better work on a remote server: **screen**.
 +
 +Assuming you never used screen on the server, you can create a new session using the command:
 +<code bash>
 +screen -S course
 +</​code>​
 +
 +//More details on this:// [[bash-using-screen|Using screen tutorial]] or [[https://​www.youtube.com/​watch?​v=hILF2MwDlUo|view a video on this]]
 +
 +===== Navigating the filesystem =====
 +
 +Now try changing directory, that means setting a new working directory:
 +<code bash>
 +cd /tmp
 +</​code>​
 +
 +Did it work? Test with ''​pwd''​.
 +
 +To return quickly to the home directory, you can use **cd** without specifying the destination path:
 +<​code>​
 +cd
 +</​code>​
 +
 +Now we are back to our home directory. So we can create a new sub-directory called //course//:
 +<code bash>
 +mkdir course
 +</​code>​
 +//More details on this, but we'll make more examples on Day2:// [[bash-intro-tree|Introduction to the filesystem]]
 +
 +
 +===== Using the manual for a command =====
 +Bundled with your distribution there is a manual. It's useful to know that is there, but it's even more useful understanding how to use it as we'll see that another very handy shell command has the very same behaviour.
 +
 +The manual command is ''​man'',​ followed by the command:
 +<code bash>
 +man ls
 +</​code>​
 +
 +When launching the manual, you'll enter an interactive page. You can:
 +  * Scroll using the arrow keys, or "Page Up" and "Page down", or the space bar to scroll down one page
 +  * ''​g''​ will go quickly to the beginning of the document, ''​G''​ to the end
 +  * ''/''​ enable a serch inside the document: type "/",​ a string and then ENTER
 +  * After a search ''​n''​ will jump to the next occurrence, ''​N''​ to the previous
 +  * Finally, ''​q''​ to quit
 +
 +===== Text editor: nano =====
 +
 +:!: Try this part yourself when you have five minutes spare.
 +
 +To create or edit a text file directly from the shell, there is a small editor called **nano**. Its basic usage is
 +<code bash>
 +nano filename.txt
 +</​code>​
 +It works like any text editor, and at the bottom there is an array of shortcuts (^ means Ctrl). ​
 +For example ''​Ctrl+X''​ to exit, or ''​Ctrl+W''​ to search for a word.
 +
 +This small video shows how to use it:
 + 
 +<​html><​br>​
 +<iframe src="​https://​player.vimeo.com/​video/​257158699"​ width="​640"​ height="​360"​ frameborder="​0"​ webkitallowfullscreen mozallowfullscreen allowfullscreen></​iframe>​
 +<br>
 +</​html>​