1 / 26

UNIX command line

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. The Shell. The shell is a program that provides an interface to the operating system. graphical shell. command-line shell.

Download Presentation

UNIX command line

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 shell command-line shell graphical interface command-line interface

  4. graphical interface

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

  6. command What happens when you double click on the icon of an application?

  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. Root (/) usr home etc var tmp bin kristian allegra phospho courses tmp data applications The directory structure 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 • Start the gedit text editor • Create a text file “myfile.txt” and save it in your home directory • 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 Commands are themselves programs %rm myfile.txt [Return] • • The shell searches the file containing the programrm • • 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. 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. General remarks • %command_name -options <file> [Return] • %man <command name> [Enter] • %whatis <command name> [Enter]

  16. General remarks • 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 up and down arrows to recall commands • The command whereis tells you where is a given program • You can use a text editor to write stuff

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

  18. Handling files and directories more less clear

  19. Redirection

  20. File system security (access rights) Each file (and directory) has associated access rights, which may be found by typing ls -l size in bytes permissions owner -rwxr-xr-- 1 gould admin 2541 2009-08-19 16:57 new_scop.txt d file's name number of links group owner date and time of the last modification Access rights on directories • 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

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

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

  23. Processes and Jobs 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 Running background processes % sleep 10 & [Enter] Backgrounding a current foreground process % sleep 100 [Ctrl Z] (^Z shortcut) % bg Listing 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 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 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. % echo $OSTYPE

  25. Setting the path 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. setenv PATH ${PATH}:/Applications/Blast set path = ($path /Applications/blast/) To add this path PERMANENTLY, add the line to your .cshrc AFTER the list of other commands

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

More Related