Basic Linux Commands
Basic Linux Commands
Liban Bashir
Network Security Administrator/
Former SYSTEM ADMIN
RHCSA / RHCE & RED HAT
VIRTUALIZATION
[email protected]
Introduction to Linux -
agenda
Login into a Linux System
Absolute & Relative Paths
Navigating the file system
LS Commands practice
session
Making directories and
deleting it.
Creating files and removing
Login into a Linux System
Two types of login screens
◦ virtual consoles (text-based)
◦ graphical logins (display managers)
Login using login name and password
Each user has a home directory for personal
file storage
*kernel
Absolute & Relative Paths
Absolute pathnames
◦ Begin with a forward slash
◦ Complete "road map" to file location
◦ Can be used anytime you wish to specify a file
name
Relative pathnames
◦ Do not begin with a slash
◦ Specify location relative to your current working
directory
◦ Can be used as a shorter way to specify a file
name
Navigating the File System
Essential navigation commands:
◦ pwd print current directory
◦ ls list files
◦ cd change directory
The ls Command
Useful options for the “ls” command:
◦ ls -a List all files, including hidden files beginning
with a period “.”
◦ ls -ld * List details about a directory and not its
contents
◦ ls -F Put an indicator character at the end of
each name
◦ ls –l Simple long listing
◦ ls –lR Recursive long listing
◦ ls –lh Give human readable file sizes
◦ ls –lS Sort files by file size
◦ ls –lt Sort files by modification time (very useful!)
The Basic Linux Command
cd, change directory
◦ cd ..
◦ cd –
◦ cd ~/mydir
◦ cd /home/usman
◦ cd
su, switch user, su – (complete user
environment)
id, print user and group ids
passwd, change password
The Basic Linux Command
cat, concatenate/display files
◦ cat /home/usman/myfile
clear, clears the screen
date, see/modify system date & time
◦ date, date [MMDDhhmm[[CC]YY][.ss]]
df, disk space usage
◦ df –h
du, file space usage
◦ du –sh
uname, print system info
◦ uname [-a, -s, -n, -r, -v, -m]
The Basic Linux Command
cp, copy files and directories
◦ cp [options] file destination
More than one file may be copied at a time if
the destination is a directory:
◦ cp [options] file1 file2 destination
If the destination is a directory, the copy is
placed there
If the destination is a file, the copy overwrites
the destination
If the destination does not exist, the copy is
renamed
Some Useful File
Commands
mv, move and/or rename files and directories
◦ mv [options] file destination
More than one file may be moved at a time if
the destination is a directory:
◦ mv [options] file1 file2 destination
In mv also, the destination works like cp
mkdir, creates directories
◦ mkdir <directory name/path>
rmdir, removes empty directories
◦ rmdir < directory name/path>
The Basic Linux Command
touch, create empty files or update file
timestamps
◦ touch <file name/path>
rm, remove files
◦ rm [options] <file name/path>
◦ rm -i file (interactive)
◦ rm -r directory (recursive)
◦ rm -f file (force)
rm –r, recursively removes directory trees
◦ rm –rf <directory name/path>
whoami, print user id
Questions?