Presentation is loading. Please wait.

Presentation is loading. Please wait.

Very Quick & Basic Unix Steven Newhouse Unix is user-friendly. It's just very selective about who its friends are.

Similar presentations

Presentation on theme: "Very Quick & Basic Unix Steven Newhouse Unix is user-friendly. It's just very selective about who its friends are."— Presentation transcript:

1 Very Quick & Basic Unix Steven Newhouse Unix is user-friendly. It's just very selective about who its friends are.

2 © Acknowledgements Ohio Supercomputing Centre (OSC) Basic & Intermediate UNIX courses With exercises: Further references Google

3 © Shells Programs Java Library Kernel UNIX and its history Its an Operating System Liaison between the user (you) and the computer Been around since the 70s Rejuvenated in the 90s with Linux Traditionally high-end machines Through Linux available nearly everywhere Programs work through a library Compositional & layered Hardware

4 © Everything is a process A process is the ‘unit’ of work in Unix A process is owned by a particular user Each user owns its own processes (partitioning) Cannot interfere with another user’s process ‘root’ is the admin or super user It can interfere with all processes Processes come from other processes They are ‘spawned’ or ‘forked’

5 © The machine in front of you It is up and running and with a login screen Login in using your username & password You will be presented with a ‘desktop’ Growing similarity to Windows desktop Usability is one of the major Linux improvements Your interaction with the machine through a terminal Start one up by navigating through the menu

6 © The Terminal (xterm) This window represents a ‘shell’ session What is a shell? A way of interacting with the computer Allows you to enter (& execute) commands By default you are in the Bash shell There are several different flavours of shells Over-time you may develop a preference Not a concern now

7 © Notation (& try out the examples) Typing a command into your terminal: $ ls $ represents the ‘prompt’ in your shell ls is the command you want to run (followed by ENTER) A command may have options prefixed by ‘ - ’ or ‘--’ $ ls –al The ls command lists directory contents Some commands have ‘arguments’ $ ls

8 © Self Help Unix has many different commands Different commands (applications) in a distribution Different shells have different build in commands Finding out about different commands apropos – simple search engine for manual pages man - display the command’s manual page -help or --help : show the built in help text

9 © What processes are running? To see the currently running processes: List the processes that you are running $ ps List the processes running on the machine $ ps –e $ ps -ef To see an updated list of processes $ top Press q to quit

10 © Exercise: Find out which shell you are in Get you shell to tell you about its environment $ env Displays a list of environment variables Each variable has a name & value One of these variables is the SHELL variable SHELL=/bin/bash To display a specific value use the echo command: $ echo $SHELL /bin/bash [is the screen output]

11 © File Hierarchy

12 © Useful Directory Commands pwd : Tells you where you are in the directory space cd : Change directory cd ~ : Change to your home (initial) directory cd /home/users/sn : Change to an absolute directory location cd../sn : Change to a relative directory location (up a level and then into the sn directory) You will have a different username than sn

13 © Other Useful Directory Commands mkdir - Create a directory rmdir - Remove a directory

14 © Manipulating files Copy a single file (after creating it: $ touch testfile1 ) $ cp testfile1 testfile2 Copy a directory (after creating it: $ mkdir testdir1 ) $ cp –pr testdir1 testdir2 Move a single file or directory (sort of rename) $ mv testfile2 testfile3 Delete a single file $ rm testfile1 HINT: Use ls to examine how the directory has changed after each command

15 © Exercise: Download a set of files Using a browser: Easy point & click – NO Using commands executed from the shell 1. Goto your home directory ( cd ) 2. Create a new sub-directory ( mkdir ) 3. Move into the subdirectory ( cd ) 4. Retrieve the file archive from the web ( wget ) 5. Expand the file archive ( tar ) 6. Look at what we’ve got ( ls )

16 © New Commands wget : Retrieve http or ftp based URLs into the current directory (Web Get) tar : Tape Archive (very old command!) User to build or extract file & directory hierarchy from an archive Examine the contents: $ tar --list –zvf How would you extract the contents instead of list? HINT: You may want to see what HELP you can get

17 © And the finally…. The file archive is: Examine the extensions:.tar – Tells you it’s a tar archive.gz – Tells you it compressed with gzip.tar.gz is frequently abbreviated to.tgz People can lie… and then the commands will normally complain

18 © Examine the download You have a directory ( bin ) with a file & a file bin/gridschool longfile.txt Examine the contents of the longfile.txt using various commands more : Allows you to control how much text goes past. A page at a time by pressing space, or a line at a time by pressing return. $ more longfile.txt less : Similar to more but allows you to go backward (b key) as well as forward (space) $ less longfile.txt

19 © Examine explicit parts of a file head : Examine the start of a text file (or just the first 5 lines) $ head longfile.txt $ head -5 longfile.txt tail : Examine the end of a text file (or just the last 5 lines) $ tail longfile.txt $ tail -5 longfile.txt grep : Look for lines with specific text $ grep HEAD logfile.txt $ grep GET longfile.txt | more $ cat longfile.txt | grep GET | more Combine commands together by ‘piping’ cat : Dumps contents to the screen

20 © Using your commands Recap on commands: Built in to the shell Standalone executable applications Standalone commands are in ‘well-known’ locations How do you find out where a command is located? $ which echo $ which export How does the shell know where to look…?

21 © Finding an executable The PATH variable tells the shell which directories to look in for an executable Directories separated by ‘:’ How do we find the value of the PATH variable $ echo $PATH $ env How do we change the value: BASH: export PATH=

22 © Add in our own executable Find the absolute location of the ‘bin’ directory in the download HINT: Navigate to the directory using: cd to move into and out of directories ls to examine the contents of the directory HINT: Once you are in the bin directory use the pwd command to find out its absolute path. Add this directory to the PATH variable (one line) $ export PATH=$PATH:/home/users/sn/download/bin:

23 © Verifying this has worked Check the executable is there $ which gridschool It will tell you the full absolute path Run the command $ gridschool Expected output: Welcome user sn to ISSGC06

24 © Editors Very simple: vi WYSIWYG: nedit More ‘normal’ editor

25 © Thank you… Questions?

Download ppt "Very Quick & Basic Unix Steven Newhouse Unix is user-friendly. It's just very selective about who its friends are."

Similar presentations

Ads by Google