Basic Shell Commands
Command Description Options Examples
• ls -l
• -l: Long format displays files and
listing. directories with detailed
• -a: Include information.
List files and hidden files • ls -a
ls
directories. hidden ones shows all files and
• -h: Human- directories, including
readable file • ls -lh
sizes. displays file sizes in a
human-readable format.
• cd /path/to/directory
changes the current
cd Change directory.
directory to the specified
path.
• pwd
Print current
pwd displays the current
working directory.
working directory.
• mkdir my_directory
Create a new
mkdir creates a new directory
directory.
named “my_directory”.
• rm [Link]
deletes the file named
“[Link]”.
• -r: Remove
• rm -r my_directory
directories
deletes the directory
Remove files and recursively.
rm “my_directory” and its
directories. • -f: Force removal
contents.
without
• rm -f [Link]
confirmation.
forcefully deletes the file
“[Link]” without
confirmation.
• cp -r directory
destination
copies the directory
• -r: Copy “directory” and its contents
Copy files and
cp directories to the specified
directories.
recursively. destination.
• cp [Link] destination
copies the file “[Link]” to
the specified destination.
Basic Shell Commands
Command Description Options Examples
• mv [Link] new_name.txt
renames the file “[Link]” to
Move/rename files “new_name.txt”.
mv
and directories. • mv [Link] directory
moves the file “[Link]” to
the specified directory.
Create an empty • touch [Link]
touch file or update file creates an empty file
timestamps. named “[Link]”.
• cat [Link]
View the contents
cat displays the contents of
of a file.
the file “[Link]”.
• head [Link]
shows the first 10 lines of
• -n: Specify the
Display the first the file “[Link]”.
head number of lines
few lines of a file. • head -n 5 [Link]
to display.
displays the first 5 lines of
the file “[Link]”.
• tail [Link]
shows the last 10 lines of
• -n: Specify the
Display the last the file “[Link]”.
tail number of lines
few lines of a file. • tail -n 5 [Link]
to display.
displays the last 5 lines of
the file “[Link]”.
• ln -s source_file
• -s: Create link_name
Create links
ln symbolic (soft) creates a symbolic link
between files.
links. named “link_name”
pointing to “source_file”.
• find /path/to/search -
• -name: Search by
name “*.txt”
Search for files filename.
find searches for all files with
and directories. • -type: Search by
the extension “.txt” in the
file type.
specified directory.