Welcome To:
Module 3
System Access and
File System
Command Prompts and Getting Prompts Back
• What are command prompts?
• A command prompt, also referred to simply as a prompt, is a short text at
the start of the command line followed by prompt symbol on a command
line interface
username hostname Prompt symbol
• To get your prompt back
• Ctrl + c
By: Imran Afzal
Access to Linux System
Each operating system has a different protocol or client that is
used to access the system
Example:
Windows = Remote Desktop (RDP)
VMware ESX = vSphere client
Linux = Putty, SecureCRT
SSH from Linux to Linux
By: Imran Afzal
Access to Linux System
By: Imran Afzal
Download and Install Putty
By: Imran Afzal
Access to Linux via Putty
By: Imran Afzal
New Network Command (ip)
• CentOS/RHEL 5 or 6 = ifconfig
• CentOS/RHEL 7 = ip
• CentOS/RHEL 7.5 and up = ifconfig
command has been deprecated
• To use ifconfig in 7.5 = “yum install
net-tools”
By: Imran Afzal
Important Things to Remember
• Linux has a super administrator account “root”
• “root” is the most powerful account that can create, modify,
delete accounts and make changes to system configuration files
• Linux is a case-sensitive system
• Avoid using file names with spaces.
By: Imran Afzal
Changing Password
• You should change your initial password as soon as you login
Command = passwd userid
Old password: - enter your current password
New password: - enter your new password
Retype new password: - re-enter your new password
By: Imran Afzal
Linux File System
• OS store data on disk drives using a structure called a filesystem, consisting of files,
directories, and the information needed to access and locate them.
• There are many different types of filesystems. In general, improvements have been made
to filesystems with new releases of operating systems, and each new filesystem has been
given a different name:
E.g. ext3, ext4, XFS, NTFS, FAT etc.
• Linux filesystems store information in a hierarchy of directories and files
By: Imran Afzal
File System Structure
By: Imran Afzal
File System Structure and its Description
/boot Contains file that is used by the boot loader (grub.cfg)
/root root user home directory. It is not same as /
/dev System devices (e.g. disk, cdrom, speakers, flashdrive, keyboard etc.)
/etc Configuration files
/bin /usr/bin Everyday user commands
/sbin /usr/sbin System/filesystem commands
/opt Optional add-on applications (Not part of OS apps)
/proc Running processes (Only exist in Memory)
/lib usr/lib C programming library files needed by commands and apps
strace -e open pwd
/tmp Directory for temporary files
/home Directory for user
/var System logs
/run System daemons that start very early (e.g. systemd and udev) to store
temporary runtime files like PID files
/mnt To mount external filesystem. (e.g. NFS)
/media For cdrom mounts.
By: Imran Afzal
Navigating File System
• When navigating a UNIX filesystem, there are a few important commands:
"cd”
"pwd”
"ls“
• "cd" stands for change directory. It is the primary command for moving you around the
filesystem.
• “pwd” stands for print working directory. It tells you where you current location is.
• “ls” stands for list. It lists all the directories/files within a current working directory
• Using of TAB key to auto-complete
By: Imran Afzal
File System Paths
• There are two paths to navigate to a filesystem
Absolute Path
Relative Path
• An absolute path always begins with a "/". This indicates that the path starts at the root directory.
An example of an absolute path is
cd /var/log/httpd
• A relative path does not begin with a "/". It identifies a location relative to your current position. An
example of a relative path is:
cd /var
cd log
cd httpd
By: Imran Afzal
Directory Listing Attributes
Total columns = 9
Type # of Links Owner Group Size Month Day Time Name
drwxr-xr-x. 21 root root 4096 Feb 27 13:33 var
lrwxrwxrwx. 1 root root 7 Feb 27 13:15 bin
-rw-r—r-- 1 root root 0 Mar 2 11:15 testfile
The second column is the number of hard links to the file. For a
directory, the number of hard links is the number of immediate
subdirectories it has plus its parent directory and itself
By: Imran Afzal
Linux File Types
By: Imran Afzal
Creating Files and Directories
• Creating Files
touch
cp
vi
• Creating Directories
mkdir
By: Imran Afzal
Find Files and Directories
• Two main commands are used to find
files/directories
• find
• locate
By: Imran Afzal
Difference Between find and locate
• locate uses a prebuilt database, which should be
regularly updated, while find iterates over a filesystem
to locate files. Thus, locate is much faster than find , but
can be inaccurate if the database (can be seen as a cache)
is not updated
• To update locate database run updatedb
By: Imran Afzal
WildCards
• A wildcard is a character that can be used as a
substitute for any of a class of characters in a
search
• * - represents zero or more characters
• ? - represents a single character
• [] - represents a range of characters
By: Imran Afzal
Soft and Hard Links
• inode = Pointer or number of a file on the hard disk
• Soft Link = Link will be removed if file is removed or renamed
• Hard Link = Deleting renaming or moving the original file will not affect
the hard link
• ln
• ln -s
By: Imran Afzal
Filesystem Color Definition
By: Imran Afzal
Filesystem Color Definition
• Blue = Directory
• Green = Executable or recognized data file e.g. cd /home/iafzal
• Sky Blue = Symbolic link file touch ca
cd /tmp
ln –s /homeiafzal/ca
Yellow with black background = Device
• Pink = Graphic image file
• Red = Archive file (tar)
Red with black background = Broken Link
e.g. cd /home/iafzal
touch ihulk
ln –s ihulk /tmp/ihulk
Absolute path for source file is missing
By: Imran Afzal