Tutorial 2
Upcoming SlideShare
Loading in...5
×
 

Tutorial 2

on

  • 3,820 views

 

Statistics

Views

Total Views
3,820
Views on SlideShare
3,817
Embed Views
3

Actions

Likes
0
Downloads
462
Comments
0

1 Embed 3

http://www.slideshare.net 3

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Tutorial 2 Tutorial 2 Presentation Transcript

  • Linux Overview
  • Outline
    • Linux file system (FS)
      • Useful commands for manipulating the FS
    • Linux vs. Windows
    • What did you learn from Assignment #1
      • sudo
      • Apt-get
      • Pipes
      • Command prompt
  • Linux Filesystem Everything is a File
  • Linux Filesystem
    • Filesystem is a method for storing and organizing computer files and the data they contain to make it easy to find and access.
    • Different operating systems normally use different file systems.
  • Linux Filesystem
    • The filesystem in Linux stores
      • the kernel
      • the executable commands supported by the OS
      • configuration information
      • user data
      • and special files that are used to give controlled access to system hardware and OS functions.
  • Linux Filesystem
    • Items stored in the filesystem are of four types:
      • Ordinary files contain text, data, or program information. Files can not contain other files or directories.
      • Directories containers that hold files, and other directories.
      • Devices are used in the same way as ordinary files providing applications with easy access to the hardware devices.
      • Links which is a pointer to another file
  • Linux Filesystem
    • The system is laid out as a hierarchical tree structure. The top-level directory is the 'root' designated by a slash '/'.
    • Each directory can have many child directories, but only one parent directory.
  • Linux Filesystem
  • Linux Filesystem
    • The path to a certain location can be specified as:
      • Absolute path from root
      • e.g.
      • /root/home/will
      • Relative path
      • e.g.
      • Accessing play from user “zeb”
      • ../will/play
  • Root Common Subdirectories
  • 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
  • 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
  • Useful Commands
  • CD
    • $ cd path
      • 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).
    • $ cd 
      • resets your current working directory to your home directory (useful if you get lost).
    • $ cd - 
      • If you change into a directory and you subsequently want to return to your original directory, use
  • pwd
    • pwd - Displays the current directory ("working directory").
    • pwd displays the full absolute path to your current location in the filesystem.
    • $ pwd 
    •     /usr/bin
    • implies that /usr/bin is the current working directory.
  • Filesystem Comparison Linux vs. Window
  • 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
  • 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 “”
  • Default Directory
    • The default working directory is your user home directory.
      • /home/ubuntu
    • /home is equivalent to My documents
    User name
  • Running Privileged Commands
    • How to run privileged commands as a normal user?
      • Use sudo command
    • Sudo is a program which can be used by normal users to execute as super users or any other users.
  • Running Privileged Commands Example
    • Running the following statement
    • sudo –l
    • Then entering password will produce a listing of command that the user may execute as well as how and as who they maybe executed.
  • Beware of the dark side of root
    • 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...
    • 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).
    • 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.
  • Using the root account
    • In case you really want to use root ...
    • If you have the root password: su - ( s witch u ser)
    • In modern distributions, the sudo command gives you access to some root privileges with your own user password. Example: sudo mount /dev/hda4 /home
  • Live process activity
    • top - Displays most important processes, sorted by cpu percentage
    • 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
    • You can change the sorting order by typing M : Memory usage, P : %CPU, T : Time.
    • You can kill a task by typing k and the process id.
  • Updating and installing packages
    • Debian-based distros use a software installer called apt-get, which uses the Debian dpkg system to retrieve, unpack, and install software.
    • Apt-get is the command you use to get that software.
    • Synaptic is the GUI for apt-get
  • Pipes
    • Unix pipes are very useful to redirect the standard output of a command to the standard input of another one.
    • Examples
      • cat *.log | grep -i error | sort
      • grep -ri error . | grep -v “ignored” | sort -u > serious_errors.log
    • This one of the most powerful features in Unix shells!
  • Command prompt
    • User_name@device_name:~$
      • ubuntu@ubuntu:~$
    • Use UP arrow key to invoke previous commands
    • Use TAB to auto-complete commands
  • Conclusion
    • You need to know the difference between relative and absolute path when dealing with Linux directories
    • You need to know how Linux FS is different from Windows FS
    • You need to know when to switch to super user privileges
  • References
    • The basic similarities between Linux and DOS
      • http://www.control-escape.com/linux/lx-basics.html
    • Introduction to Unix
      • http://wwwhomes.doc.ic.ac.uk/~wjk/UnixIntro/
    • Windows-to-Linux Roadmap
      • http://www.ibm.com/developerworks/linux/library/l-roadmap1.html