Linux Command Reference
1. General Commands
Command Function
date Displays the current system date and time.
date +%D Displays the date only (MM/DD/YY
format).
date +%T Displays the time only (HH:MM:SS format).
date +%Y Displays the year part of the date.
date +%H Displays the hour part of the time.
cal Displays the calendar of the current month.
cal [year] Displays the calendar for all months of the
specified year.
cal [month] [year] Displays the calendar for the specified
month and year.
who Displays login details of all users such as IP,
terminal no, and username.
who am i Displays the login details of the current
user.
uname Displays the name of the operating system.
uname -r Shows the version number of the OS
(kernel version).
uname -n Displays the domain name of the server.
echo $HOME Displays the user's home directory.
bc Starts the basic calculator. Press Ctrl+D to
quit.
lp filename Sends a file to the printer queue.
man [command] Displays the manual page for the specified
command. Press q to exit.
history Shows the list of previously used
commands in the current session.
exit Exits the current shell or process. If shell is
the only process, logs out.
2. Directory Commands
Command Function
pwd Displays the path of the present working
directory.
mkdir [dirname] Creates a directory with the given name in
the current directory.
mkdir dir1 dir2 ... Creates multiple directories at once under
the current directory.
cd [subdir] Changes to the specified sub-directory.
Absolute if path starts with `/`.
cd Switches to the user's home directory.
cd / Switches to the root directory.
cd .. Moves back to the parent directory.
rmdir [subdir] Removes an empty sub-directory.
3. File Commands
Command Function
cat > filename Creates a new file and allows typing
content into it. Press Ctrl+D to end. `>`
redirects output to a file.
cat filename Displays the contents of the specified file.
cat >> filename Appends contents to the end of the existing
file.
cp src dest Copies the file from source to destination.
Overwrites if the destination file exists.
cp -i src dest Prompts before overwriting the destination
file.
cp -r src dest Recursively copies a directory and its
entire contents.
mv old new Renames a file or directory. The `-i` option
prompts before overwriting.
mv f1 f2 f3 dir/ Moves multiple files into the specified
directory.
mv -v old new Displays the names of files as they are
moved or renamed.
rm file Deletes the specified file(s). Use `-i` to
confirm before each deletion.
rm * Deletes all files in the current directory.
rm -r * Deletes all files and subdirectories
recursively.
rm -f * Forcefully deletes files, including write-
protected ones, without prompting.
ls Lists all files and subdirectories in the
current directory.
ls name Checks if a file or directory with the given
name exists.
ls name* Lists files that match a specific pattern.
ls -a Lists all files, including hidden ones (those
starting with a dot `.`).
ls -x dirname Lists contents of a specific directory in
multi-column format.
ls -R Recursively lists all files in the directory
and its subdirectories.
ls -l Long format listing showing permissions,
ownership, size, and modification time.
cmp file1 file2 Compares two files byte by byte. Shows
nothing if they are identical.
wc filename Displays the number of lines, words, and
characters in a file.
chmod perm filename Changes permissions of the specified file.
Example: `chmod 740 file` gives full rights
to user, read-only to group, and no rights to
others.