Linux Commands

To list all Linux commands, run compgen -chelp, or man -e in your Terminal screen. Run the utility with the –help flag to check a command’s manual and options.


Base/Standard Commands:

ls, pwd, cd: Basic navigation commands used to list files, print the current directory, and change directories.

mkdir, rmdir, rm, cp, mv, touch: Basic file and directory manipulation commands.

file, grep, sed, cat: Standard text processing and file examination tools.

nano, vi: Text editors that are commonly available in most Linux distributions.

zip, tar: Standard archiving and compression tools.

Alphabetical

CommandNotes
alias
unalias
apt
dnf
awk
if
cal
cat
cat >
tac
cat: The cat command is used to concatenate and display the contents of one or more files. For example, cat file1.txt outputs the content of file1.txt to the terminal.
cat >: This command allows you to create a new file or overwrite an existing one. When you run cat > newfile.txt, you can type text directly, and it will be saved to newfile.txt after pressing Ctrl+D to end the input.
tac: The tac command outputs the contents of a file in reverse order, from the last line to the first. For example, tac file1.txt will display the lines of file1.txt in reverse order.
cat > with multiple files: The cat > command can also be used to combine the contents of multiple files into a single new file. For example, cat file1.txt file2.txt > combined.txt will merge the contents of file1.txt and file2.txt into a new file named combined.txt.
cdThe cd command is used to change the current directory. You can specify the path to the desired directory, or use cd .. to move up one level in the directory structure. If no path is provided, cd will take you to your home directory.
cd –The cd - command switches you back to the previous directory you were in. It’s useful for quickly toggling between two directories.
command | head
command | tail
chmod
chown
cpThe cp command is used to copy files and directories from one location to another. By default, it copies files to the specified destination, preserving the original file. To copy directories, you need to use the -r option for recursive copying.
cut
-f
-b
-c
-d
cURL
df
du
diff
-c
-i
dig
echo
fileThe file command is used to determine the type of a file by examining its content rather than relying on its extension. When you run file followed by a filename, it outputs a brief description of the file type, such as whether it’s a text file, a binary executable, an image, or another format. This command is useful for quickly identifying unknown files.
file -kThe file -k command is an extended version of the file command that continues processing files, even those identified as empty or special files. The -k option ensures that the command shows all possible matches for a file type, rather than stopping at the first match.
find
grepThe grep command is used to search for specific patterns or text within files. It scans the file line by line and outputs lines that match the given pattern. You can use various options with grep, such as -i for case-insensitive search, -r for recursive search through directories, and -v to display lines that do not match the pattern. This command is powerful for filtering and finding information within large files or across multiple files.
head
history
hostname
in
ip
jobs
kill
locate
lsThe ls command lists the files and directories in the current directory. By default, it shows the names of items in a simple format. You can use options like -l for detailed information or -a to include hidden files.
ls | grep
man
manual
mkdirThe mkdir command is used to create a new directory. You can specify the name of the directory you want to create, and it will be made in the current location by default. You can also create multiple directories at once or use options like -p to create parent directories as needed.
mvThe mv command is used to move or rename files and directories. When you move a file or directory, it is transferred to a new location, and when you rename it, the name changes without altering the file’s location. If the destination is a directory, the source files or directories are moved into it. Rename: mv old_name.txt new_name.txt. If you specify the full path, you can simultaneously rename files and move them to a new location.
nano
jed
vi
nano, jed, and vi are text editors commonly used in Linux:
nano: A simple and user-friendly text editor that is easy for beginners. It displays helpful shortcuts at the bottom of the screen and is often pre-installed on many Linux distributions.
jed: A lightweight text editor that offers more features than nano but is still relatively simple. It supports multiple emulations, such as emacs and WordStar, making it versatile for users familiar with other editors.
vi: A powerful and widely used text editor that is more complex and feature-rich. It operates in different modes (e.g., insert mode, command mode) and requires familiarity with its commands, making it better suited for experienced users.
All three are useful for editing text files directly in the terminal, with varying levels of complexity and functionality.
netstat
nslookup
passwd
ping
ping -c | tail
pwdThe pwd command displays the full path of the current working directory. It shows where you are in the directory structure. This is useful for confirming your location in the filesystem.
rmdirThe rmdir command is used to remove empty directories. If the directory contains files or other directories, the command will fail unless those contents are removed first. To delete non-empty directories, you would need to use a different command like rm -r.
rmThe rm command is used to remove files or directories. By default, it deletes files, but if you want to remove a directory, you need to use the -r option for recursive deletion. Be cautious with this command, as it permanently deletes the specified files or directories without moving them to a trash or recycle bin.
Add the -r option to remove a folder and its contents, including subdirectories. Use the -i flag to display a confirmation message before the removal or -f to deactivate it completely.
rm -rThe rm -r command is used to recursively delete directories and their contents, including all files and subdirectories within them. This command is powerful and should be used with caution, as it will remove everything in the specified directory without asking for confirmation by default. If you want to be prompted before each deletion, you can add the -i option (rm -ri).
rsync
scp
sedThe sed command is a stream editor used for searching, finding, and replacing text within files or streams of text. It processes text line by line and allows you to perform text transformations directly in the command line. Common uses include:
Substitution: Replace occurrences of a pattern with a new string using sed 's/old/new/' file.txt.
In-place editing: Modify a file directly by using the -i option, e.g., sed -i 's/old/new/' file.txt.
Deleting lines: Remove specific lines, such as sed '3d' file.txt, which deletes the third line of the file.
sed is powerful for automating text modifications in scripts and command-line workflows.
shutdown
sort
sudo
su
systemctl
tarThe tar command is used to create, extract, and manage archive files in the .tar format. It can bundle multiple files and directories into a single archive file, which is useful for backups and transfers. Common options include -c to create an archive, -x to extract it, and -v for verbose output, often combined as tar -cvf (for creating) or tar -xvf (for extracting).
tee
time
top
htop

ps (-A -r -u)
touchThe touch command is used to create an empty file or update the timestamp of an existing file. If the file doesn’t exist, touch will create it; if it does exist, the command updates the file’s last modified and access times. This is useful for creating placeholder files or refreshing file timestamps.
traceroute
uname
useradd
userdel
watch
wget
whoami
zip
unzip
The zip command is used to compress files or directories into a .zip archive. By default, it creates a new archive containing the specified files or directories, reducing their size and combining them into a single file. You can use options like -r to include directories and their contents recursively. The unzip command is used to extract the contents of a .zip archive. By default, it extracts the files into the current directory, preserving the original directory structure within the archive. You can also specify a different directory for extraction or use options like -l to list the contents without extracting them.

Leave a Reply

Your email address will not be published. Required fields are marked *