Presentation is loading. Please wait.

Presentation is loading. Please wait.

UNIX command line. In this module you will learn: What is the computer shell What is the command line interface What is the directory tree Some UNIX commands.

Similar presentations


Presentation on theme: "UNIX command line. In this module you will learn: What is the computer shell What is the command line interface What is the directory tree Some UNIX commands."— Presentation transcript:

1 UNIX command line

2 In this module you will learn: What is the computer shell What is the command line interface What is the directory tree Some UNIX commands

3 The Shell The shell is a program that provides an interface to the operating system graphical interface graphical shellcommand-line shell command-line interface

4 graphical interface

5 What happens when you double click on the icon of an application?

6 command

7 command-line interface prompt Here you write the command

8 Open a command-line terminal on your computer

9 You can type the application name (+ options) in the command-line terminal screen and then type [Return] command

10 The directory structure Root (/) home bin etcvartmpusr allegrakristian courses applications data phospho tmp The file-system is arranged in a hierarchical structure, like an inverted tree The top of the hierarchy is traditionally called root When you first login, your current working directory is your home directory

11 Access you home directory using the command-line interface Create a text file “myfile.txt” and save it in your home directory Start the gedit text editor Go to the command-line interface and type “ls” at the prompt

12 About UNIX Everything in Unix is either a file or a process A process is an executing program identified by a unique PID (PID = Process IDentifier) A file is a collection of data

13 About Unix commands %rm myfile.txt [Return] The shell searches the file containing the program rm executes the program rm on myfile.txt After the process rm myfile.txt has finished running, the shell returns the prompt % to you, indicating that it is waiting for further commands. Commands are themselves programs Here you can type a new command

14 General remarks If you've made a typo: CTRL-u to cancel the whole line Unix is case-sensitive There are commands that can take options The options change the behaviour of the command UNIX uses command-line completion

15 %command_name -options [Return] %man [Enter] %whatis [Enter] General remarks

16 CTRL-A sets the cursor at the beginning of the line CTRL-E sets the cursor at the end of the line You can use a text editor to write stuff You can use up and down arrows to recall commands The command whereis tells you where is a given program General remarks

17 Listing files and directories The directories ‘. ’, ‘.. ’, and ‘ ~ ’ % ls -a [Enter] % cd. [Enter] % cd.. [Enter] % ls ~/oeiras

18 Handling files and directories clearlessmore

19 Redirection

20 File system security (access rights) -rwxr-xr-- 1 gould admin 2541 2009-08-19 16:57 new_scop.txt Each file (and directory) has associated access rights, which may be found by typing ls -l permissions number of links owner group owner size in bytes date and time of the last modification file's name r allows users to list files in the directory w allows users to delete files from the directory or move files into it x allow users to access files in the directory Access rights on directories d

21 Changing access rights: chmod %chmod go-rwx myfile.txt %chmod a+rw biglist

22 Running your program from the command line %python test.py %pymol %chmod a+x test.py %test.py BUT: #!/usr/bin/python

23 Processes and Jobs Backgrounding a current foreground process Listing processes A process may be in the foreground, in the background, or be suspended Backgrounding a long process has the effect that the Unix prompt is returned immediately, and other tasks can be carried out while the original process continues executing % sleep 10 & [Enter] % sleep 100 [Ctrl Z] (^Z shortcut) % bg Running background processes % ps #list of processes with their associated PID and status % jobs #list of running processes % fg %jobnumber #restart (foreground) suspended process % fg #restart(foreground) the last suspended process

24 UNIX Variables % echo $OSTYPE shell variables apply only to the current instance of the shell and are used to set short-term working conditions environment variables have a farther reaching significance, and those set at login are valid for the duration of the session. Variables are a way of passing information from the shell to programs when you run them Some are set by the system, others by you, yet others by the shell, or any program that loads another program

25 When you type a command, your path (or PATH ) variable defines in which directories the shell will look to find the command you typed. If the system returns a message saying " command : Command not found", this indicates that either the command doesn't exist at all on the system or it is simply not in your path. Setting the path set path = ($path /Applications/blast/) To add this path PERMANENTLY, add the line to your.cshrc AFTER the list of other commands setenv PATH ${PATH}:/Applications/Blast

26 Transferring files between and connecting to remote hosts % scp % sftp password: $ cd $ get TargetFile $ put SourceFile wget [option]... [URL]... [URL]: http://host[:port]/directory/file ftp://host[:port]/directory/file % ssh user@hostuser@host Password:


Download ppt "UNIX command line. In this module you will learn: What is the computer shell What is the command line interface What is the directory tree Some UNIX commands."

Similar presentations


Ads by Google