Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Tutorial 2


Published on

Published in: Business, Technology
  • Be the first to comment

Tutorial 2

  1. 1. Linux Overview
  2. 2. Outline <ul><li>Linux file system (FS) </li></ul><ul><ul><li>Useful commands for manipulating the FS </li></ul></ul><ul><li>Linux vs. Windows </li></ul><ul><li>What did you learn from Assignment #1 </li></ul><ul><ul><li>sudo </li></ul></ul><ul><ul><li>Apt-get </li></ul></ul><ul><ul><li>Pipes </li></ul></ul><ul><ul><li>Command prompt </li></ul></ul>
  3. 3. Linux Filesystem Everything is a File
  4. 4. Linux Filesystem <ul><li>Filesystem is a method for storing and organizing computer files and the data they contain to make it easy to find and access. </li></ul><ul><li>Different operating systems normally use different file systems. </li></ul>
  5. 5. Linux Filesystem <ul><li>The filesystem in Linux stores </li></ul><ul><ul><li>the kernel </li></ul></ul><ul><ul><li>the executable commands supported by the OS </li></ul></ul><ul><ul><li>configuration information </li></ul></ul><ul><ul><li>user data </li></ul></ul><ul><ul><li>and special files that are used to give controlled access to system hardware and OS functions. </li></ul></ul>
  6. 6. Linux Filesystem <ul><li>Items stored in the filesystem are of four types: </li></ul><ul><ul><li>Ordinary files contain text, data, or program information. Files can not contain other files or directories. </li></ul></ul><ul><ul><li>Directories containers that hold files, and other directories. </li></ul></ul><ul><ul><li>Devices are used in the same way as ordinary files providing applications with easy access to the hardware devices. </li></ul></ul><ul><ul><li>Links which is a pointer to another file </li></ul></ul>
  7. 7. Linux Filesystem <ul><li>The system is laid out as a hierarchical tree structure. The top-level directory is the 'root' designated by a slash '/'. </li></ul><ul><li>Each directory can have many child directories, but only one parent directory. </li></ul>
  8. 8. Linux Filesystem
  9. 9. Linux Filesystem <ul><li>The path to a certain location can be specified as: </li></ul><ul><ul><li>Absolute path from root </li></ul></ul><ul><ul><li>e.g. </li></ul></ul><ul><ul><li>/root/home/will </li></ul></ul><ul><ul><li>Relative path </li></ul></ul><ul><ul><li>e.g. </li></ul></ul><ul><ul><li>Accessing play from user “zeb” </li></ul></ul><ul><ul><li>../will/play </li></ul></ul>
  10. 10. Root Common Subdirectories
  11. 11. Common Subdirectories Directory Stands for Content / root Top-level directory in the hierarchical tree /bin Binaries Contains binaries used by both the system administrator and non-privileged user e.g. command ‘ls’ is stored here /dev Devices Contains hardware devices directories. It is a virtual directory /etc Et cetra Contains configuration files for running applications /home Contains user subdirectories /lib Libraries Contains shared libraries e.g. C, Perl, Python general libraries /mnt Mount /proc Processes Contains information about the system e.g. process that are running. It is a virtual directory /root Default home directory for the system administrator. Isolated to increase security
  12. 12. Common Subdirectories Directory Stands for Content /sbin Secure Binaries Contains secured binaries that are only accessed by privileged users e.g. fdisk, partitioning tool is kept here /tmp Temporaries Contains temporary files /usr Unix System Resources Contains subdirectories such as /usr/doc which contains system documentations, /usr/local the local hosts directory /var Variables Contains log and spool files /boot Contains Linux kernel
  13. 13. Useful Commands
  14. 14. CD <ul><li>$ cd path </li></ul><ul><ul><li>changes your current working directory to path (which can be an absolute or a relative path). One of the most common relative paths to use is '..' (i.e. the parent directory of the current directory). </li></ul></ul><ul><li>$ cd  </li></ul><ul><ul><li>resets your current working directory to your home directory (useful if you get lost). </li></ul></ul><ul><li>$ cd -  </li></ul><ul><ul><li>If you change into a directory and you subsequently want to return to your original directory, use </li></ul></ul>
  15. 15. pwd <ul><li>pwd - Displays the current directory (&quot;working directory&quot;). </li></ul><ul><li>pwd displays the full absolute path to your current location in the filesystem. </li></ul><ul><li>$ pwd  </li></ul><ul><li>    /usr/bin </li></ul><ul><li>implies that /usr/bin is the current working directory. </li></ul>
  16. 16. Filesystem Comparison Linux vs. Window
  17. 17. Filesystem Comparison Linux Filesystem Windows Filesystem Hierarchal Structure Only a single hierarchal directory structure. Everything starts from the root directory and then expanded to subdirectories. It also has various partitions, but under the root directory. They are ‘mounted’ under specific directories (Unified scheme) Various partitions, with directories under those partitions (Volume based file hierarchy) Detection Partition will not be detected unless it has been mounted. All partitioned detected and booted, then each assigned a drive letter. Crossover Can read/write FAT16 , FAT32 Can not unless with third party support Hidden Files Implement with a name that starts with a dot. Tracks it as a file attribute Types ext2, ext3 FAT12, FAT16, FAT32, and or NTFS
  18. 18. Filesystem Comparison Linux Filesystem Windows Filesystem Case Sensitivity Case sensitive. File.txt is not the same as file.txt Not case sensitive Confirmation Messages Non existent e.g. when deleting, user will not be promoted whether to continue with the operation or not User will be prompted with each action Search Path Does not look into the current directories. It looks at the PATH environment variable. To run program in current directory: ./ program Checks current directory first then looks at the PATH environment variable Slashes Uses a forward slash “/” Uses a backward slash “” Switch Indication Switches are preceded by “-” Switches are preceded by “”
  19. 19. Default Directory <ul><li>The default working directory is your user home directory. </li></ul><ul><ul><li>/home/ubuntu </li></ul></ul><ul><li>/home is equivalent to My documents </li></ul>User name
  20. 20. Running Privileged Commands <ul><li>How to run privileged commands as a normal user? </li></ul><ul><ul><li>Use sudo command </li></ul></ul><ul><li>Sudo is a program which can be used by normal users to execute as super users or any other users. </li></ul>
  21. 21. Running Privileged Commands Example <ul><li>Running the following statement </li></ul><ul><li>sudo –l </li></ul><ul><li>Then entering password will produce a listing of command that the user may execute as well as how and as who they maybe executed. </li></ul>
  22. 22. Beware of the dark side of root <ul><li>root user privileges are only needed for very specific tasks with security risks: mounting, creating device files, loading drivers, starting networking, changing file ownership, package upgrades... </li></ul><ul><li>Even if you have the root password, your regular account should be sufficient for 99.9 % of your tasks (unless you are a system administrator). </li></ul><ul><li>In assignments, it is acceptable to use root . In real life, you may not even have access to this account, or put your systems and data at risk if you do. </li></ul>
  23. 23. Using the root account <ul><li>In case you really want to use root ... </li></ul><ul><li>If you have the root password: su - ( s witch u ser) </li></ul><ul><li>In modern distributions, the sudo command gives you access to some root privileges with your own user password. Example: sudo mount /dev/hda4 /home </li></ul>
  24. 24. Live process activity <ul><li>top - Displays most important processes, sorted by cpu percentage </li></ul><ul><li>top - 15:44:33 up 1:11, 5 users, load average: 0.98, 0.61, 0.59 Tasks: 81 total, 5 running, 76 sleeping, 0 stopped, 0 zombie Cpu(s): 92.7% us, 5.3% sy, 0.0% ni, 0.0% id, 1.7% wa, 0.3% hi, 0.0% si Mem: 515344k total, 512384k used, 2960k free, 20464k buffers Swap: 1044184k total, 0k used, 1044184k free, 277660k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 3809 jdoe 25 0 6256 3932 1312 R 93.8 0.8 0:21.49 bunzip2 2769 root 16 0 157m 80m 90m R 2.7 16.0 5:21.01 X 3006 jdoe 15 0 30928 15m 27m S 0.3 3.0 0:22.40 kdeinit 3008 jdoe 16 0 5624 892 4468 S 0.3 0.2 0:06.59 autorun 3034 jdoe 15 0 26764 12m 24m S 0.3 2.5 0:12.68 kscd 3810 jdoe 16 0 2892 916 1620 R 0.3 0.2 0:00.06 top </li></ul><ul><li>You can change the sorting order by typing M : Memory usage, P : %CPU, T : Time. </li></ul><ul><li>You can kill a task by typing k and the process id. </li></ul>
  25. 25. Updating and installing packages <ul><li>Debian-based distros use a software installer called apt-get, which uses the Debian dpkg system to retrieve, unpack, and install software. </li></ul><ul><li>Apt-get is the command you use to get that software. </li></ul><ul><li>Synaptic is the GUI for apt-get </li></ul>
  26. 26. Pipes <ul><li>Unix pipes are very useful to redirect the standard output of a command to the standard input of another one. </li></ul><ul><li>Examples </li></ul><ul><ul><li>cat *.log | grep -i error | sort </li></ul></ul><ul><ul><li>grep -ri error . | grep -v “ignored” | sort -u > serious_errors.log </li></ul></ul><ul><li>This one of the most powerful features in Unix shells! </li></ul>
  27. 27. Command prompt <ul><li>User_name@device_name:~$ </li></ul><ul><ul><li>ubuntu@ubuntu:~$ </li></ul></ul><ul><li>Use UP arrow key to invoke previous commands </li></ul><ul><li>Use TAB to auto-complete commands </li></ul>
  28. 28. Conclusion <ul><li>You need to know the difference between relative and absolute path when dealing with Linux directories </li></ul><ul><li>You need to know how Linux FS is different from Windows FS </li></ul><ul><li>You need to know when to switch to super user privileges </li></ul>
  29. 29. References <ul><li>The basic similarities between Linux and DOS </li></ul><ul><ul><li> </li></ul></ul><ul><li>Introduction to Unix </li></ul><ul><ul><li> </li></ul></ul><ul><li>Windows-to-Linux Roadmap </li></ul><ul><ul><li> </li></ul></ul>