
Introduction to Linux CLI
- Mohammad Abu Mattar
- Linux
- 19 Oct, 2022
- 51 Mins read
Introduction
The Linux operating system family is a group of free and open-source Unix systems. They consist of Red Hat, Arch Linux, Ubuntu, Debian, openSUSE, and Fedora. You must utilize a shell when using Linux, an application that allows you access to the system’s features. The majority of Linux distributions have a graphical user interface (GUI), which makes them user-friendly for beginners. I advise using the command-line interface (CLI), as it is speedier and gives you more control. By putting commands into the CLI, tasks that take many steps on the GUI may be completed in a matter of seconds.
What Is a Linux Command?
An application or tool that runs on the CLI, a console that communicates with the system via text and processes, is known as a Linux command. It resembles Windows’ Command Prompt program in many ways. By hitting Enter at the end of the line, Linux commands are run on the terminal. You may use commands to carry out a range of operations, including managing users, installing packages, and manipulating files.
The general syntax of a Linux command is as follows:
CommandName [flag(s)] [parameter(s)]
- CommandName is the name of the command you want to run.
- Flag(s) are optional arguments that modify the behavior of the command.
- Parameter(s) are required arguments that specify the command’s input.
Note: Remember that case affects the syntax of every Linux command.
File Management
Every system administrator should be familiar with the very basic commands listed in this section. This collection of Linux commands for managing files is undoubtedly incomplete, but it can serve as a starting point and cover the majority of simple to complicated situations.
pwd
The pwd
command is used to print the current working directory. The working directory is the directory you are currently in. The output of the pwd
command is the path to the working directory.
# Print the current working directorypwd
pwd
Flags
-L
- If the current working directory is a symbolic link, print the path of the symbolic link.-P
- If the current working directory is a symbolic link, print the path of the symbolic link’s target.
# Print the current working directorypwd -L
# Print the current working directorypwd -P
ls
ls
is A system’s files and directories are listed using the ls
command. It will display the contents of the current working directory when run without a flag or argument.
# List the contents of the current working directoryls
ls
Flags
-a
- List all files, including hidden files.-l
- List files in long format.-h
- List files in human-readable format.-r
- List files in reverse order.-t
- List files by the time they were last modified.
# List all files, including hidden filesls -a
# List files in long formatls -l
# List files in human-readable formatls -h
# List files in reverse orderls -r
# List files by the time they were last modifiedls -t
cd
The cd
command is used to change the current working directory. It takes a directory as an argument. The output of the cd
command is the new working directory.
# Change the current working directory to the home directorycd ~
mkdir
The mkdir
command is used to create a new directory. It takes a directory name as an argument. The output of the mkdir
command is the newly created directory.
# Create a new directory named "new-directory"mkdir new-directory
mkdir
Flags
-p
- Create parent directories as needed.
# Create a new directory named "new-directory" and its parent directoriesmkdir -p new-directory
touch
The touch
command is used to create a new file. It takes a file name as an argument. The output of the touch
command is the newly created file.
# Create a new file named "new-file"touch new-file
touch
Flags
-a
- Change the access time of the file.-m
- Change the modification time of the file.-t
- Change the access and modification times of the file.
# Change the access time of the filetouch -a new-file
# Change the modification time of the filetouch -m new-file
# Change the access and modification times of the filetouch -t new-file
cp
The cp
command is used to copy files and directories. It takes the source and destination as arguments. The output of the cp
command is the copied file or directory.
# Copy the file "file" to the directory "directory"cp file directory
cp
Flags
-r
- Copy directories recursively.
# Copy the directory "directory" to the directory "new-directory"cp -r directory new-directory
mv
The mv
command is used to move files and directories. It takes the source and destination as arguments. The output of the mv
command is the moved file or directory.
# Move the file "file" to the directory "directory"mv file directory
mv
Flags
-i
- Prompt before overwriting an existing file.-f
- Force the move of a file, even if it already exists.-u
- Move a file only if the source file is newer than the destination file.
# Move the file "file" to the directory "directory" and prompt before overwriting an existing filemv -i file directory
# Move the file "file" to the directory "directory" and force the move of a file, even if it already existsmv -f file directory
# Move the file "file" to the directory "directory" and move a file only if the source file is newer than the destination filemv -u file directory
rm
The rm
command is used to remove files and directories. It takes the file or directory as an argument. The output of the rm
command is the removed file or directory.
# Remove the file "file"rm file
rm
Flags
-r
- Remove directories and their contents recursively.-f
- Force remove files without prompting for confirmation.
# Remove the directory "directory" and its contents recursivelyrm -r directory
# Remove the file "file" without prompting for confirmationrm -f file
rmdir
The rmdir
command is used to remove empty directories. It takes the directory as an argument. The output of the rmdir
command is the removed directory.
# Remove the directory "directory"rmdir directory
rmdir
Flags
-p
- Remove parent directories as needed.
# Remove the directory "directory" and its parent directoriesrmdir -p directory
cat
The cat
command is used to display the contents of a file. It takes a file as an argument. The output of the cat
command is the contents of the specified file.
# Display the contents of the file "file"cat file
cat
Flags
-n
- Number all output lines.
# Display the contents of the file "file" and number all output linescat -n file
more
The more
command is used to display the contents of a file. It takes a file as an argument. The output of the more
command is the contents of the specified file.
# Display the contents of the file "file"more file
more
Flags
-d
- Display the contents of the file “file” and number all output lines.
# Display the contents of the file "file" and number all output linesmore -d file
less
The less
command is used to display the contents of a file. It takes a file as an argument. The output of the less
command is the contents of the specified file.
# Display the contents of the file "file"less file
less
Flags
-N
- Display the contents of the file “file” and number all output lines.
# Display the contents of the file "file" and number all output linesless -N file
head
The head
command is used to display the first 10 lines of a file. It takes a file as an argument. The output of the head
command is the first 10 lines of the specified file.
# Display the first 10 lines of the file "file"head file
head
Flags
-n
- Display the first n lines of the file “file”.
# Display the first 5 lines of the file "file"head -n 5 file
tail
The tail
command is used to display the last 10 lines of a file. It takes a file as an argument. The output of the tail
command is the last 10 lines of the specified file.
# Display the last 10 lines of the file "file"tail file
tail
Flags
-n
- Display the last n lines of the file “file”.
# Display the last 5 lines of the file "file"tail -n 5 file
Finding files and directories
The find command will be used the majority of the time to locate files and folders. But I also enjoy the which command since it provides the binary’s path, which is necessary on several occasions when we must run a binary with a complete PATH.
find
The find
command is used to find files and directories. It takes a directory as an argument. The output of the find
command is the files and directories that match the specified criteria.
# Find all files and directories in the current directoryfind .
find
Flags
-name
- Find files and directories with the specified name.-type
- Find files and directories of the specified type.-size
- Find files and directories of the specified size.-mtime
- Find files and directories that have been modified in the specified number of days.-exec
- Execute the specified command on the found files and directories.
# Find all files and directories in the current directory with the name "file"find . -name file
# Find all files and directories in the current directory of the type "file"find . -type file
# Find all files and directories in the current directory of the size "1M"find . -size 1M
# Find all files and directories in the current directory that have been modified in the last 5 daysfind . -mtime 5
# Find all files and directories in the current directory with the name "file" and execute the command "ls" on themfind . -name file -exec ls {} \;
locate
The locate
command is used to find files and directories. It takes a file or directory name as an argument. The output of the locate
command is the files and directories that match the specified criteria.
# Find all files and directories in the current directory with the name "file"locate file
locate
Flags
-i
- Find files and directories with the specified name, ignoring case.
# Find all files and directories in the current directory with the name "file" ignoring caselocate -i file
which
The which
command is used to find the location of a command. It takes a command as an argument. The output of the which
command is the location of the specified command.
# Find the location of the command "command"which command
which
Flags
-a
- Find all locations of the specified command.-s
- Find the location of the specified command and return a status code of 0 if the command is found and 1 if the command is not found.
# Find all locations of the command "command"which -a command
# Find the location of the command "command" and return a status code of 0 if the command is found and 1 if the command is not foundwhich -s command
whereis
The whereis
command is used to find the location of a command. It takes a command as an argument. The output of the whereis
command is the location of the specified command.
# Find the location of the command "command"whereis command
whereis
Flags
-b
- Find the location of the specified command and return a status code of 0 if the command is found and 1 if the command is not found.
# Find the location of the command "command" and return a status code of 0 if the command is found and 1 if the command is not foundwhereis -b command
Check User Information
These are a few of the commands we employ to verify the details of the most recent person to log in, as well as a few others to obtain further information regarding an existing user.
whoami
The whoami
command is used to display the current user. It takes no arguments. The output of the whoami
command is the current user.
# Display the current userwhoami
whoami
Flags
-u
- Display the current user and return a status code of 0 if the user is found and 1 if the user is not found.
# Display the current user and return a status code of 0 if the user is found and 1 if the user is not foundwhoami -u
who
The who
command is used to display the current users. It takes no arguments. The output of the who
command is the current users.
# Display the current userswho
who
Flags
-u
- Display the current users and return a status code of 0 if the users are found and 1 if the users are not found.
# Display the current users and return a status code of 0 if the users are found and 1 if the users are not foundwho -u
w
The w
command is used to display the current users. It takes no arguments. The output of the w
command is the current users.
# Display the current usersw
w
Flags
-u
- Display the current users and return a status code of 0 if the users are found and 1 if the users are not found.
# Display the current users and return a status code of 0 if the users are found and 1 if the users are not foundw -u
id
The id
command is used to display the current user. It takes no arguments. The output of the id
command is the current user.
# Display the current userid
id
Flags
-u
- Display the current user and return a status code of 0 if the user is found and 1 if the user is not found.
# Display the current user and return a status code of 0 if the user is found and 1 if the user is not foundid -u
groups
The groups
command is used to display the current user’s groups. It takes no arguments. The output of the groups
command is the current user’s groups.
# Display the current user's groupsgroups
Managing Users and Groups
These are some of the fundamental Linux commands for managing users, including adding, editing, and removing individuals or groups.
useradd
The useradd
command is used to add a user. It takes a username as an argument. The output of the useradd
command is the user that was added.
# Add a user with the username "user"useradd user
useradd
Flags
-c
- Add a user with the specified comment.-d
- Add a user with the specified home directory.-g
- Add a user with the specified primary group.-G
- Add a user with the specified supplementary groups.-m
- Add a user with the specified home directory.-s
- Add a user with the specified shell.-u
- Add a user with the specified user ID.
# Add a user with the username "user" and comment "comment"useradd -c "comment" user
# Add a user with the username "user" and home directory "/home/user"useradd -d /home/user user
# Add a user with the username "user" and primary group "group"useradd -g group user
# Add a user with the username "user" and supplementary groups "group1", "group2", and "group3"useradd -G group1,group2,group3 user
# Add a user with the username "user" and home directory "/home/user"useradd -m /home/user user
# Add a user with the username "user" and shell "/bin/sh"useradd -s /bin/sh user
# Add a user with the username "user" and user ID "1000"useradd -u 1000 user
userdel
The userdel
command is used to delete a user. It takes a username as an argument. The output of the userdel
command is the user that was deleted.
# Delete a user with the username "user"userdel user
userdel
Flags
-r
- Delete a user with the specified home directory.
# Delete a user with the username "user" and home directory "/home/user"userdel -r /home/user user
usermod
The usermod
command is used to modify a user. It takes a username as an argument. The output of the usermod
command is the user that was modified.
# Modify a user with the username "user"usermod user
usermod
Flags
-c
- Modify a user with the specified comment.-d
- Modify a user with the specified home directory.-e
- Modify a user with the specified expiration date.-g
- Modify a user with the specified primary group.-G
- Modify a user with the specified supplementary groups.-l
- Modify a user with the specified username.-m
- Modify a user with the specified home directory.-s
- Modify a user with the specified shell.-u
- Modify a user with the specified user ID.
# Modify a user with the username "user" and comment "comment"usermod -c "comment" user
# Modify a user with the username "user" and home directory "/home/user"usermod -d /home/user user
# Modify a user with the username "user" and expiration date "2023-01-01"usermod -e 2023-01-01 user
# Modify a user with the username "user" and primary group "group"usermod -g group user
# Modify a user with the username "user" and supplementary groups "group1", "group2", and "group3"usermod -G group1,group2,group3 user
# Modify a user with the username "user" and username "user2"usermod -l user2 user
# Modify a user with the username "user" and home directory "/home/user"usermod -m /home/user user
# Modify a user with the username "user" and shell "/bin/sh"usermod -s /bin/sh user
# Modify a user with the username "user" and user ID "1000"usermod -u 1000 user
passwd
The passwd
command is used to change a user’s password. It takes a username as an argument. The output of the passwd
command is the user’s password that was changed.
# Change a user's password with the username "user"passwd user
passwd
Flags
-d
- Change a user’s password with the specified username and delete the password.-e
- Change a user’s password with the specified username and expire the password.-l
- Change a user’s password with the specified username and lock the password.-u
- Change a user’s password with the specified username and unlock the password.
# Change a user's password with the username "user" and delete the passwordpasswd -d user
# Change a user's password with the username "user" and expire the passwordpasswd -e user
# Change a user's password with the username "user" and lock the passwordpasswd -l user
# Change a user's password with the username "user" and unlock the passwordpasswd -u user
groupadd
The groupadd
command is used to add a group. It takes a group name as an argument. The output of the groupadd
command is the group that was added.
# Add a group with the group name "group"groupadd group
groupadd
Flags
-g
- Add a group with the specified group ID.-r
- Add a group with the specified system group.-f
- Add a group with the specified force.
# Add a group with the group name "group" and group ID "1000"groupadd -g 1000 group
# Add a group with the group name "group" and system groupgroupadd -r group
# Add a group with the group name "group" and forcegroupadd -f group
groupdel
The groupdel
command is used to delete a group. It takes a group name as an argument. The output of the groupdel
command is the group that was deleted.
# Delete a group with the group name "group"groupdel group
groupdel
Flags
-f
- Delete a group with the specified force.
# Delete a group with the group name "group" and forcegroupdel -f group
groupmod
The groupmod
command is used to modify a group. It takes a group name as an argument. The output of the groupmod
command is the group that was modified.
# Modify a group with the group name "group"groupmod group
groupmod
Flags
-g
- Modify a group with the specified group ID.-n
- Modify a group with the specified group name.
# Modify a group with the group name "group" and group ID "1000"groupmod -g 1000 group
# Modify a group with the group name "group" and group name "group2"groupmod -n group2 group
Managing Permissions
I have simply addressed the fundamental commands that we use to assign, change, and remove rights from files and directories because the topic of Linux permissions is rather broad.
chown
The chown
command is used to change the owner of a file or directory. It takes a username and a file or directory as arguments. The output of the chown
command is the file or directory that was changed.
# Change the owner of a file or directory with the username "user" and file or directory "/home/user/file"chown user /home/user/file
chown
Flags
-R
- Change the owner of a file or directory with the specified recursive.-c
- Change the owner of a file or directory with the specified verbose.-f
- Change the owner of a file or directory with the specified force.-h
- Change the owner of a file or directory with the specified symbolic links.-v
- Change the owner of a file or directory with the specified verbose.
# Change the owner of a file or directory with the username "user" and file or directory "/home/user/file" and recursivechown -R user /home/user/file
# Change the owner of a file or directory with the username "user" and file or directory "/home/user/file" and verbosechown -c user /home/user/file
# Change the owner of a file or directory with the username "user" and file or directory "/home/user/file" and forcechown -f user /home/user/file
# Change the owner of a file or directory with the username "user" and file or directory "/home/user/file" and symbolic linkschown -h user /home/user/file
# Change the owner of a file or directory with the username "user" and file or directory "/home/user/file" and verbosechown -v user /home/user/file
chgrp
The chgrp
command is used to change the group of a file or directory. It takes a group name and a file or directory as arguments. The output of the chgrp
command is the file or directory that was changed.
# Change the group of a file or directory with the group name "group" and file or directory "/home/user/file"chgrp group /home/user/file
chgrp
Flags
-R
- Change the group of a file or directory with the specified recursive.-c
- Change the group of a file or directory with the specified verbose.-f
- Change the group of a file or directory with the specified force.-h
- Change the group of a file or directory with the specified symbolic links.-v
- Change the group of a file or directory with the specified verbose.
# Change the group of a file or directory with the group name "group" and file or directory "/home/user/file" and recursivechgrp -R group /home/user/file
# Change the group of a file or directory with the group name "group" and file or directory "/home/user/file" and verbosechgrp -c group /home/user/file
# Change the group of a file or directory with the group name "group" and file or directory "/home/user/file" and forcechgrp -f group /home/user/file
# Change the group of a file or directory with the group name "group" and file or directory "/home/user/file" and symbolic linkschgrp -h group /home/user/file
# Change the group of a file or directory with the group name "group" and file or directory "/home/user/file" and verbosechgrp -v group /home/user/file
chmod
The chmod
command is used to change the permissions of a file or directory. It takes a permission and a file or directory as arguments. The output of the chmod
command is the file or directory that was changed.
# Change the permissions of a file or directory with the permission "777" and file or directory "/home/user/file"chmod 777 /home/user/file
Note: The
chmod
command can also be used to change the permissions of a file or directory using the symbolic notation. 777 is the same asrwxrwxrwx
. The first character is for the owner, the second character is for the group, and the third character is for everyone else. 7 is the same asrwx
. 6 is the same asrw-
. 5 is the same asr-x
. 4 is the same asr--
. 3 is the same as-wx
. 2 is the same as-w-
. 1 is the same as--x
. 0 is the same as---
.
chmod
Flags
-R
- Change the permissions of a file or directory with the specified recursive.-c
- Change the permissions of a file or directory with the specified verbose.-f
- Change the permissions of a file or directory with the specified force.-h
- Change the permissions of a file or directory with the specified symbolic links.-v
- Change the permissions of a file or directory with the specified verbose.
# Change the permissions of a file or directory with the permission "777" and file or directory "/home/user/file" and recursivechmod -R 777 /home/user/file
# Change the permissions of a file or directory with the permission "777" and file or directory "/home/user/file" and verbosechmod -c 777 /home/user/file
# Change the permissions of a file or directory with the permission "777" and file or directory "/home/user/file" and forcechmod -f 777 /home/user/file
# Change the permissions of a file or directory with the permission "777" and file or directory "/home/user/file" and symbolic linkschmod -h 777 /home/user/file
# Change the permissions of a file or directory with the permission "777" and file or directory "/home/user/file" and verbosechmod -v 777 /home/user/file
newgrp
The newgrp
command is used to change the group of the current user. It takes a group name as an argument. The output of the newgrp
command is the group that was changed.
# Change the group of the current user with the group name "group"newgrp group
newgrp
Flags
-
- Change the group of the current user with the specified login shell.-l
- Change the group of the current user with the specified login shell.-s
- Change the group of the current user with the specified login shell.
# Change the group of the current user with the group name "group" and login shellnewgrp - group
# Change the group of the current user with the group name "group" and login shellnewgrp -l group
# Change the group of the current user with the group name "group" and login shellnewgrp -s group
setfacl
The setfacl
command is used to set the access control list of a file or directory. It takes a file or directory as an argument. The output of the setfacl
command is the file or directory that was changed.
# Set the access control list of a file or directory with the file or directory "/home/user/file"setfacl /home/user/file
setfacl
Flags
-m
- Set the access control list of a file or directory with the specified modify.-x
- Set the access control list of a file or directory with the specified remove.-b
- Set the access control list of a file or directory with the specified remove all.-k
- Set the access control list of a file or directory with the specified remove default.-R
- Set the access control list of a file or directory with the specified recursive.-c
- Set the access control list of a file or directory with the specified verbose.-f
- Set the access control list of a file or directory with the specified force.-h
- Set the access control list of a file or directory with the specified symbolic links.-v
- Set the access control list of a file or directory with the specified verbose.
# Set the access control list of a file or directory with the file or directory "/home/user/file" and modifysetfacl -m /home/user/file
# Set the access control list of a file or directory with the file or directory "/home/user/file" and removesetfacl -x /home/user/file
# Set the access control list of a file or directory with the file or directory "/home/user/file" and remove allsetfacl -b /home/user/file
# Set the access control list of a file or directory with the file or directory "/home/user/file" and remove defaultsetfacl -k /home/user/file
# Set the access control list of a file or directory with the file or directory "/home/user/file" and recursivesetfacl -R /home/user/file
# Set the access control list of a file or directory with the file or directory "/home/user/file" and verbosesetfacl -c /home/user/file
# Set the access control list of a file or directory with the file or directory "/home/user/file" and forcesetfacl -f /home/user/file
# Set the access control list of a file or directory with the file or directory "/home/user/file" and symbolic linkssetfacl -h /home/user/file
# Set the access control list of a file or directory with the file or directory "/home/user/file" and verbosesetfacl -v /home/user/file
umask
The umask
command is used to set the default permissions of a file or directory. It takes a permission as an argument. The output of the umask
command is the permission that was changed.
# Set the default permissions of a file or directory with the permission "777"umask 777
umask
Flags
-S
- Set the default permissions of a file or directory with the specified symbolic notation.
# Set the default permissions of a file or directory with the permission "777" and symbolic notationumask -S 777
getfacl
The getfacl
command is used to get the access control list of a file or directory. It takes a file or directory as an argument. The output of the getfacl
command is the access control list of the file or directory.
# Get the access control list of a file or directory with the file or directory "/home/user/file"getfacl /home/user/file
getfacl
Flags
-R
- Get the access control list of a file or directory with the specified recursive.-c
- Get the access control list of a file or directory with the specified verbose.-f
- Get the access control list of a file or directory with the specified force.-h
- Get the access control list of a file or directory with the specified symbolic links.-v
- Get the access control list of a file or directory with the specified verbose.
# Get the access control list of a file or directory with the file or directory "/home/user/file" and recursivegetfacl -R /home/user/file
# Get the access control list of a file or directory with the file or directory "/home/user/file" and verbosegetfacl -c /home/user/file
# Get the access control list of a file or directory with the file or directory "/home/user/file" and forcegetfacl -f /home/user/file
# Get the access control list of a file or directory with the file or directory "/home/user/file" and symbolic linksgetfacl -h /home/user/file
# Get the access control list of a file or directory with the file or directory "/home/user/file" and verbosegetfacl -v /home/user/file
chattr
The chattr
command is used to change the attributes of a file or directory. It takes a file or directory as an argument. The output of the chattr
command is the file or directory that was changed.
# Change the attributes of a file or directory with the file or directory "/home/user/file"chattr /home/user/file
chattr
Flags
-i
- Change the attributes of a file or directory with the specified immutable.-a
- Change the attributes of a file or directory with the specified append only.-A
- Change the attributes of a file or directory with the specified no append.-d
- Change the attributes of a file or directory with the specified no dump.-D
- Change the attributes of a file or directory with the specified dump.-e
- Change the attributes of a file or directory with the specified extent.-E
- Change the attributes of a file or directory with the specified no extent.-h
- Change the attributes of a file or directory with the specified no follow.-H
- Change the attributes of a file or directory with the specified follow.-j
- Change the attributes of a file or directory with the specified data journaling.-J
- Change the attributes of a file or directory with the specified no data journaling.-s
- Change the attributes of a file or directory with the specified secure deletion.-S
- Change the attributes of a file or directory with the specified no secure deletion.-t
- Change the attributes of a file or directory with the specified notail.-T
- Change the attributes of a file or directory with the specified tail.-u
- Change the attributes of a file or directory with the specified undelete.-U
- Change the attributes of a file or directory with the specified no undelete.-v
- Change the attributes of a file or directory with the specified verbose.
# Change the attributes of a file or directory with the file or directory "/home/user/file" and immutablechattr -i /home/user/file
# Change the attributes of a file or directory with the file or directory "/home/user/file" and append onlychattr -a /home/user/file
# Change the attributes of a file or directory with the file or directory "/home/user/file" and no appendchattr -A /home/user/file
# Change the attributes of a file or directory with the file or directory "/home/user/file" and no dumpchattr -d /home/user/file
# Change the attributes of a file or directory with the file or directory "/home/user/file" and dumpchattr -D /home/user/file
# Change the attributes of a file or directory with the file or directory "/home/user/file" and extentchattr -e /home/user/file
# Change the attributes of a file or directory with the file or directory "/home/user/file" and no extentchattr -E /home/user/file
# Change the attributes of a file or directory with the file or directory "/home/user/file" and no followchattr -h /home/user/file
# Change the attributes of a file or directory with the file or directory "/home/user/file" and followchattr -H /home/user/file
# Change the attributes of a file or directory with the file or directory "/home/user/file" and data journalingchattr -j /home/user/file
# Change the attributes of a file or directory with the file or directory "/home/user/file" and no data journalingchattr -J /home/user/file
# Change the attributes of a file or directory with the file or directory "/home/user/file" and secure deletionchattr -s /home/user/file
# Change the attributes of a file or directory with the file or directory "/home/user/file" and no secure deletionchattr -S /home/user/file
# Change the attributes of a file or directory with the file or directory "/home/user/file" and notailchattr -t /home/user/file
# Change the attributes of a file or directory with the file or directory "/home/user/file" and tailchattr -T /home/user/file
# Change the attributes of a file or directory with the file or directory "/home/user/file" and undeletechattr -u /home/user/file
# Change the attributes of a file or directory with the file or directory "/home/user/file" and no undeletechattr -U /home/user/file
# Change the attributes of a file or directory with the file or directory "/home/user/file" and verbosechattr -v /home/user/file
lsattr
The lsattr
command is used to list the attributes of a file or directory. It takes a file or directory as an argument. The output of the lsattr
command is the attributes of the file or directory.
# List the attributes of a file or directory with the file or directory "/home/user/file"lsattr /home/user/file
lsattr
Flags
-R
- List the attributes of a file or directory with the specified recursive.-a
- List the attributes of a file or directory with the specified all.-d
- List the attributes of a file or directory with the specified directory.-h
- List the attributes of a file or directory with the specified symbolic links.-l
- List the attributes of a file or directory with the specified long format.-v
- List the attributes of a file or directory with the specified verbose.
# List the attributes of a file or directory with the file or directory "/home/user/file" and recursivelsattr -R /home/user/file
# List the attributes of a file or directory with the file or directory "/home/user/file" and alllsattr -a /home/user/file
# List the attributes of a file or directory with the file or directory "/home/user/file" and directorylsattr -d /home/user/file
# List the attributes of a file or directory with the file or directory "/home/user/file" and symbolic linkslsattr -h /home/user/file
# List the attributes of a file or directory with the file or directory "/home/user/file" and long formatlsattr -l /home/user/file
# List the attributes of a file or directory with the file or directory "/home/user/file" and verboselsattr -v /home/user/file
Check System Information
You must be acquainted with these commands if you want to be a system and Linux administrator. These, such as load, CPU model, hardware model, hardware type, etc., will assist you in identifying the sort of server you are using.
uptime
The uptime
command is used to display the system uptime. It takes no arguments. The output of the uptime
command is the system uptime.
# Display the system uptimeuptime
uptime
Flags
-p
- Display the system uptime with the specified pretty format.-s
- Display the system uptime with the specified since.-V
- Display the system uptime with the specified version.
# Display the system uptime with the specified pretty formatuptime -p
# Display the system uptime with the specified sinceuptime -s
# Display the system uptime with the specified versionuptime -V
uname
The uname
command is used to display the system information. It takes no arguments. The output of the uname
command is the system information.
# Display the system informationuname
uname
Flags
-a
- Display the system information with the specified all.-m
- Display the system information with the specified machine.-n
- Display the system information with the specified nodename.-r
- Display the system information with the specified kernel release.-s
- Display the system information with the specified kernel name.-v
- Display the system information with the specified kernel version.
# Display the system information with the specified alluname -a
# Display the system information with the specified machineuname -m
# Display the system information with the specified nodenameuname -n
# Display the system information with the specified kernel releaseuname -r
# Display the system information with the specified kernel nameuname -s
# Display the system information with the specified kernel versionuname -v
lscpu
The lscpu
command is used to display the CPU information. It takes no arguments. The output of the lscpu
command is the CPU information.
# Display the CPU informationlscpu
lscpu
Flags
-a
- Display the CPU information with the specified all.-e
- Display the CPU information with the specified extended.-h
- Display the CPU information with the specified human-readable.-i
- Display the CPU information with the specified size in bytes.-p
- Display the CPU information with the specified physical.-x
- Display the CPU information with the specified XML.
# Display the CPU information with the specified alllscpu -a
# Display the CPU information with the specified extendedlscpu -e
# Display the CPU information with the specified human-readablelscpu -h
# Display the CPU information with the specified size in byteslscpu -i
# Display the CPU information with the specified physicallscpu -p
# Display the CPU information with the specified XMLlscpu -x
lspci
The lspci
command is used to display the PCI information. It takes no arguments. The output of the lspci
command is the PCI information.
# Display the PCI informationlspci
lspci
Flags
-a
- Display the PCI information with the specified all.-b
- Display the PCI information with the specified brief.-d
- Display the PCI information with the specified device.-D
- Display the PCI information with the specified dump.-k
- Display the PCI information with the specified kernel.-n
- Display the PCI information with the specified numeric.-s
- Display the PCI information with the specified slot.-t
- Display the PCI information with the specified tree.-v
- Display the PCI information with the specified verbose.
# Display the PCI information with the specified alllspci -a
# Display the PCI information with the specified brieflspci -b
# Display the PCI information with the specified devicelspci -d
# Display the PCI information with the specified dumplspci -D
# Display the PCI information with the specified kernellspci -k
# Display the PCI information with the specified numericlspci -n
# Display the PCI information with the specified slotlspci -s
# Display the PCI information with the specified treelspci -t
# Display the PCI information with the specified verboselspci -v
lsusb
The lsusb
command is used to display the USB information. It takes no arguments. The output of the lsusb
command is the USB information.
# Display the USB informationlsusb
lsusb
Flags
-a
- Display the USB information with the specified all.-b
- Display the USB information with the specified brief.-d
- Display the USB information with the specified device.-D
- Display the USB information with the specified dump.-k
- Display the USB information with the specified kernel.-n
- Display the USB information with the specified numeric.-s
- Display the USB information with the specified slot.-t
- Display the USB information with the specified tree.-v
- Display the USB information with the specified verbose.
# Display the USB information with the specified alllsusb -a
# Display the USB information with the specified brieflsusb -b
# Display the USB information with the specified devicelsusb -d
# Display the USB information with the specified dumplsusb -D
# Display the USB information with the specified kernellsusb -k
# Display the USB information with the specified numericlsusb -n
# Display the USB information with the specified slotlsusb -s
# Display the USB information with the specified treelsusb -t
# Display the USB information with the specified verboselsusb -v
free
The free
command is used to display the memory information. It takes no arguments. The output of the free
command is the memory information.
# Display the memory informationfree
free
Flags
-b
- Display the memory information with the specified bytes.-k
- Display the memory information with the specified kilobytes.-m
- Display the memory information with the specified megabytes.-g
- Display the memory information with the specified gigabytes.-h
- Display the memory information with the specified human-readable.-t
- Display the memory information with the specified total.-s
- Display the memory information with the specified seconds.-c
- Display the memory information with the specified continuous.-o
- Display the memory information with the specified omit header.-V
- Display the memory information with the specified version.
# Display the memory information with the specified bytesfree -b
# Display the memory information with the specified kilobytesfree -k
# Display the memory information with the specified megabytesfree -m
# Display the memory information with the specified gigabytesfree -g
# Display the memory information with the specified human-readablefree -h
# Display the memory information with the specified totalfree -t
# Display the memory information with the specified secondsfree -s
# Display the memory information with the specified continuousfree -c
# Display the memory information with the specified omit headerfree -o
# Display the memory information with the specified versionfree -V
Configure and Troubleshoot Network
Network engineers fresh to the Linux environment can benefit from reading this section. I made an effort to include the most used network troubleshooting commands. Tcpdump, iperf, netperf, and several more networking tools are also available for debugging network-related problems, but because of their complexity, they are not included in this list.
ifconfig
The ifconfig
command is used to configure and display the network interface information. It takes no arguments. The output of the ifconfig
command is the network interface information.
# Display the network interface informationifconfig
ifconfig
Flags
-a
- Display the network interface information with the specified all.-s
- Display the network interface information with the specified summary.-v
- Display the network interface information with the specified verbose.-V
- Display the network interface information with the specified version.
# Display the network interface information with the specified allifconfig -a
# Display the network interface information with the specified summaryifconfig -s
# Display the network interface information with the specified verboseifconfig -v
# Display the network interface information with the specified versionifconfig -V
ip
The ip
command is used to configure and display the network interface information. It takes no arguments. The output of the ip
command is the network interface information.
# Display the network interface informationip
ip
Flags
-s
- Display the network interface information with the specified statistics.-d
- Display the network interface information with the specified details.-h
- Display the network interface information with the specified help.-v
- Display the network interface information with the specified verbose.-V
- Display the network interface information with the specified version.
# Display the network interface information with the specified statisticsip -s
# Display the network interface information with the specified detailsip -d
# Display the network interface information with the specified helpip -h
# Display the network interface information with the specified verboseip -v
# Display the network interface information with the specified versionip -V
netstat
The netstat
command is used to display the network information. It takes no arguments. The output of the netstat
command is the network information.
# Display the network informationnetstat
netstat
Flags
-a
- Display the network information with the specified all.-c
- Display the network information with the specified continuous.-e
- Display the network information with the specified extended.-g
- Display the network information with the specified multicast.-i
- Display the network information with the specified interfaces.-l
- Display the network information with the specified listening.-m
- Display the network information with the specified memory.-n
- Display the network information with the specified numeric.-p
- Display the network information with the specified protocol.-r
- Display the network information with the specified routing.
# Display the network information with the specified allnetstat -a
# Display the network information with the specified continuousnetstat -c
# Display the network information with the specified extendednetstat -e
# Display the network information with the specified multicastnetstat -g
# Display the network information with the specified interfacesnetstat -i
# Display the network information with the specified listeningnetstat -l
# Display the network information with the specified memorynetstat -m
# Display the network information with the specified numericnetstat -n
# Display the network information with the specified protocolnetstat -p
# Display the network information with the specified routingnetstat -r
route
The route
command is used to display the routing information. It takes no arguments. The output of the route
command is the routing information.
# Display the routing informationroute
route
Flags
-n
- Display the routing information with the specified numeric.-v
- Display the routing information with the specified verbose.-V
- Display the routing information with the specified version.
# Display the routing information with the specified numericroute -n
# Display the routing information with the specified verboseroute -v
# Display the routing information with the specified versionroute -V
ethtool
The ethtool
command is used to display the network interface information. It takes no arguments. The output of the ethtool
command is the network interface information.
# Display the network interface informationethtool
ethtool
Flags
-a
- Display the network interface information with the specified all.-i
- Display the network interface information with the specified interface.-k
- Display the network interface information with the specified kernel.-S
- Display the network interface information with the specified statistics.-c
- Display the network interface information with the specified command.-h
- Display the network interface information with the specified help.-V
- Display the network interface information with the specified version.
# Display the network interface information with the specified allethtool -a
# Display the network interface information with the specified interfaceethtool -i
# Display the network interface information with the specified kernelethtool -k
# Display the network interface information with the specified statisticsethtool -S
# Display the network interface information with the specified commandethtool -c
# Display the network interface information with the specified helpethtool -h
# Display the network interface information with the specified versionethtool -V
tcpdump
The tcpdump
command is used to capture and display the network packets. It takes no arguments. The output of the tcpdump
command is the network packets.
# Capture and display the network packetstcpdump
tcpdump
Flags
-c
- Capture and display the network packets with the specified count.-i
- Capture and display the network packets with the specified interface.-n
- Capture and display the network packets with the specified numeric.-r
- Capture and display the network packets with the specified read.-s
- Capture and display the network packets with the specified snapshot.-w
- Capture and display the network packets with the specified write.-A
- Capture and display the network packets with the specified ASCII.-C
- Capture and display the network packets with the specified file.-D
- Capture and display the network packets with the specified devices.-F
- Capture and display the network packets with the specified output.-G
- Capture and display the network packets with the specified rotate.-H
- Capture and display the network packets with the specified hex.-L
- Capture and display the network packets with the specified follow.-N
- Capture and display the network packets with the specified no.-S
- Capture and display the network packets with the specified size.-T
- Capture and display the network packets with the specified timestamp.-Z
- Capture and display the network packets with the specified user.-d
- Capture and display the network packets with the specified decode.-V
- Capture and display the network packets with the specified version.
# Capture and display the network packets with the specified counttcpdump -c
# Capture and display the network packets with the specified interfacetcpdump -i
# Capture and display the network packets with the specified numerictcpdump -n
# Capture and display the network packets with the specified readtcpdump -r
# Capture and display the network packets with the specified snapshottcpdump -s
# Capture and display the network packets with the specified writetcpdump -w
# Capture and display the network packets with the specified ASCIItcpdump -A
# Capture and display the network packets with the specified filetcpdump -C
# Capture and display the network packets with the specified devicestcpdump -D
# Capture and display the network packets with the specified outputtcpdump -F
# Capture and display the network packets with the specified rotatetcpdump -G
# Capture and display the network packets with the specified hextcpdump -H
# Capture and display the network packets with the specified followtcpdump -L
# Capture and display the network packets with the specified notcpdump -N
# Capture and display the network packets with the specified sizetcpdump -S
# Capture and display the network packets with the specified timestamptcpdump -T
# Capture and display the network packets with the specified usertcpdump -Z
# Capture and display the network packets with the specified decodetcpdump -d
# Capture and display the network packets with the specified versiontcpdump -V
ping
The ping
command is used to send the ICMP echo request packets to the specified host. It takes no arguments. The output of the ping
command is the ICMP echo reply packets.
# Send the ICMP echo request packets to the specified hostping <host>
ping
Flags
-c
- Send the ICMP echo request packets to the specified host with the specified count.-i
- Send the ICMP echo request packets to the specified host with the specified interval.-I
- Send the ICMP echo request packets to the specified host with the specified interface.-s
- Send the ICMP echo request packets to the specified host with the specified size.-t
- Send the ICMP echo request packets to the specified host with the specified ttl.-v
- Send the ICMP echo request packets to the specified host with the specified verbose.-V
- Send the ICMP echo request packets to the specified host with the specified version.
# Send the ICMP echo request packets to the specified host with the specified countping -c <host>
# Send the ICMP echo request packets to the specified host with the specified intervalping -i <host>
# Send the ICMP echo request packets to the specified host with the specified interfaceping -I <host>
# Send the ICMP echo request packets to the specified host with the specified sizeping -s <host>
# Send the ICMP echo request packets to the specified host with the specified ttlping -t <host>
# Send the ICMP echo request packets to the specified host with the specified verboseping -v <host>
# Send the ICMP echo request packets to the specified host with the specified versionping -V <host>
traceroute
The traceroute
command is used to trace the route to the specified host. It takes no arguments. The output of the traceroute
command is the route to the specified host.
# Trace the route to the specified hosttraceroute <host>
traceroute
Flags
-d
- Trace the route to the specified host with the specified debug.-f
- Trace the route to the specified host with the specified first.-g
- Trace the route to the specified host with the specified gateway.-I
- Trace the route to the specified host with the specified interface.-m
- Trace the route to the specified host with the specified max.-n
- Trace the route to the specified host with the specified numeric.-p
- Trace the route to the specified host with the specified port.-q
- Trace the route to the specified host with the specified query.-s
- Trace the route to the specified host with the specified source.-t
- Trace the route to the specified host with the specified ttl.-v
- Trace the route to the specified host with the specified verbose.-V
- Trace the route to the specified host with the specified version.
# Trace the route to the specified host with the specified debugtraceroute -d <host>
# Trace the route to the specified host with the specified firsttraceroute -f <host>
# Trace the route to the specified host with the specified gatewaytraceroute -g <host>
# Trace the route to the specified host with the specified interfacetraceroute -I <host>
# Trace the route to the specified host with the specified maxtraceroute -m <host>
# Trace the route to the specified host with the specified numerictraceroute -n <host>
# Trace the route to the specified host with the specified porttraceroute -p <host>
# Trace the route to the specified host with the specified querytraceroute -q <host>
# Trace the route to the specified host with the specified sourcetraceroute -s <host>
# Trace the route to the specified host with the specified ttltraceroute -t <host>
# Trace the route to the specified host with the specified verbosetraceroute -v <host>
# Trace the route to the specified host with the specified versiontraceroute -V <host>
dig
The dig
command is used to query the DNS name servers. It takes no arguments. The output of the dig
command is the DNS name servers.
# Query the DNS name serversdig <host>
dig
Flags
-a
- Query the DNS name servers with the specified all.-b
- Query the DNS name servers with the specified bind.-c
- Query the DNS name servers with the specified class.-d
- Query the DNS name servers with the specified debug.-f
- Query the DNS name servers with the specified file.-i
- Query the DNS name servers with the specified interface.-k
- Query the DNS name servers with the specified key.-m
- Query the DNS name servers with the specified max.-n
- Query the DNS name servers with the specified numeric.-p
- Query the DNS name servers with the specified port.-q
- Query the DNS name servers with the specified query.-r
- Query the DNS name servers with the specified recurse.-s
- Query the DNS name servers with the specified server.-t
- Query the DNS name servers with the specified type.-v
- Query the DNS name servers with the specified verbose.-V
- Query the DNS name servers with the specified version.
# Query the DNS name servers with the specified alldig -a <host>
# Query the DNS name servers with the specified binddig -b <host>
# Query the DNS name servers with the specified classdig -c <host>
# Query the DNS name servers with the specified debugdig -d <host>
# Query the DNS name servers with the specified filedig -f <host>
# Query the DNS name servers with the specified interfacedig -i <host>
# Query the DNS name servers with the specified keydig -k <host>
# Query the DNS name servers with the specified maxdig -m <host>
# Query the DNS name servers with the specified numericdig -n <host>
# Query the DNS name servers with the specified portdig -p <host>
# Query the DNS name servers with the specified querydig -q <host>
# Query the DNS name servers with the specified recursedig -r <host>
# Query the DNS name servers with the specified serverdig -s <host>
# Query the DNS name servers with the specified typedig -t <host>
# Query the DNS name servers with the specified verbosedig -v <host>
# Query the DNS name servers with the specified versiondig -V <host>
nslookup
The nslookup
command is used to query the DNS name servers. It takes no arguments. The output of the nslookup
command is the DNS name servers.
# Query the DNS name serversnslookup <host>
nslookup
Flags
-a
- Query the DNS name servers with the specified all.-b
- Query the DNS name servers with the specified bind.-c
- Query the DNS name servers with the specified class.-d
- Query the DNS name servers with the specified debug.-f
- Query the DNS name servers with the specified file.-i
- Query the DNS name servers with the specified interface.-k
- Query the DNS name servers with the specified key.-m
- Query the DNS name servers with the specified max.-n
- Query the DNS name servers with the specified numeric.-p
- Query the DNS name servers with the specified port.-q
- Query the DNS name servers with the specified query.-r
- Query the DNS name servers with the specified recurse.-s
- Query the DNS name servers with the specified server.-t
- Query the DNS name servers with the specified type.-v
- Query the DNS name servers with the specified verbose.-V
- Query the DNS name servers with the specified version.
# Query the DNS name servers with the specified allnslookup -a <host>
# Query the DNS name servers with the specified bindnslookup -b <host>
# Query the DNS name servers with the specified classnslookup -c <host>
# Query the DNS name servers with the specified debugnslookup -d <host>
# Query the DNS name servers with the specified filenslookup -f <host>
# Query the DNS name servers with the specified interfacenslookup -i <host>
# Query the DNS name servers with the specified keynslookup -k <host>
# Query the DNS name servers with the specified maxnslookup -m <host>
# Query the DNS name servers with the specified numericnslookup -n <host>
# Query the DNS name servers with the specified portnslookup -p <host>
# Query the DNS name servers with the specified querynslookup -q <host>
# Query the DNS name servers with the specified recursenslookup -r <host>
# Query the DNS name servers with the specified servernslookup -s <host>
# Query the DNS name servers with the specified typenslookup -t <host>
# Query the DNS name servers with the specified verbosenslookup -v <host>
# Query the DNS name servers with the specified versionnslookup -V <host>
host
The host
command is used to query the DNS name servers. It takes no arguments. The output of the host
command is the DNS name servers.
# Query the DNS name servershost <host>
host
Flags
-a
- Query the DNS name servers with the specified all.-b
- Query the DNS name servers with the specified bind.-c
- Query the DNS name servers with the specified class.-d
- Query the DNS name servers with the specified debug.-f
- Query the DNS name servers with the specified file.-i
- Query the DNS name servers with the specified interface.-k
- Query the DNS name servers with the specified key.-m
- Query the DNS name servers with the specified max.-n
- Query the DNS name servers with the specified numeric.-p
- Query the DNS name servers with the specified port.-q
- Query the DNS name servers with the specified query.-r
- Query the DNS name servers with the specified recurse.-s
- Query the DNS name servers with the specified server.-t
- Query the DNS name servers with the specified type.-v
- Query the DNS name servers with the specified verbose.-V
- Query the DNS name servers with the specified version.
# Query the DNS name servers with the specified allhost -a <host>
# Query the DNS name servers with the specified bindhost -b <host>
# Query the DNS name servers with the specified classhost -c <host>
# Query the DNS name servers with the specified debughost -d <host>
# Query the DNS name servers with the specified filehost -f <host>
# Query the DNS name servers with the specified interfacehost -i <host>
# Query the DNS name servers with the specified keyhost -k <host>
# Query the DNS name servers with the specified maxhost -m <host>
# Query the DNS name servers with the specified numerichost -n <host>
# Query the DNS name servers with the specified porthost -p <host>
# Query the DNS name servers with the specified queryhost -q <host>
# Query the DNS name servers with the specified recursehost -r <host>
# Query the DNS name servers with the specified serverhost -s <host>
# Query the DNS name servers with the specified typehost -t <host>
# Query the DNS name servers with the specified verbosehost -v <host>
# Query the DNS name servers with the specified versionhost -V <host>
drill
The drill
command is used to query the DNS name servers. It takes no arguments. The output of the drill
command is the DNS name servers.
# Query the DNS name serversdrill <host>
drill
Flags
-a
- Query the DNS name servers with the specified all.-b
- Query the DNS name servers with the specified bind.-c
- Query the DNS name servers with the specified class.-d
- Query the DNS name servers with the specified debug.-f
- Query the DNS name servers with the specified file.-i
- Query the DNS name servers with the specified interface.-k
- Query the DNS name servers with the specified key.-m
- Query the DNS name servers with the specified max.-n
- Query the DNS name servers with the specified numeric.-p
- Query the DNS name servers with the specified port.-q
- Query the DNS name servers with the specified query.-r
- Query the DNS name servers with the specified recurse.-s
- Query the DNS name servers with the specified server.-t
- Query the DNS name servers with the specified type.-v
- Query the DNS name servers with the specified verbose.-V
- Query the DNS name servers with the specified version.
# Query the DNS name servers with the specified alldrill -a <host>
# Query the DNS name servers with the specified binddrill -b <host>
# Query the DNS name servers with the specified classdrill -c <host>
# Query the DNS name servers with the specified debugdrill -d <host>
# Query the DNS name servers with the specified filedrill -f <host>
# Query the DNS name servers with the specified interfacedrill -i <host>
# Query the DNS name servers with the specified keydrill -k <host>
# Query the DNS name servers with the specified maxdrill -m <host>
# Query the DNS name servers with the specified numericdrill -n <host>
# Query the DNS name servers with the specified portdrill -p <host>
# Query the DNS name servers with the specified querydrill -q <host>
# Query the DNS name servers with the specified recursedrill -r <host>
# Query the DNS name servers with the specified serverdrill -s <host>
# Query the DNS name servers with the specified typedrill -t <host>
# Query the DNS name servers with the specified verbosedrill -v <host>
# Query the DNS name servers with the specified versiondrill -V <host>
ss
The ss
command is used to query the DNS name servers. It takes no arguments. The output of the ss
command is the DNS name servers.
# Query the DNS name serversss <host>
ss
Flags
-a
- Query the DNS name servers with the specified all.-b
- Query the DNS name servers with the specified bind.-c
- Query the DNS name servers with the specified class.-d
- Query the DNS name servers with the specified debug.-f
- Query the DNS name servers with the specified file.-i
- Query the DNS name servers with the specified interface.-k
- Query the DNS name servers with the specified key.-m
- Query the DNS name servers with the specified max.-n
- Query the DNS name servers with the specified numeric.-p
- Query the DNS name servers with the specified port.-q
- Query the DNS name servers with the specified query.-r
- Query the DNS name servers with the specified recurse.-s
- Query the DNS name servers with the specified server.-t
- Query the DNS name servers with the specified type.-v
- Query the DNS name servers with the specified verbose.-V
- Query the DNS name servers with the specified version.
# Query the DNS name servers with the specified allss -a <host>
# Query the DNS name servers with the specified bindss -b <host>
# Query the DNS name servers with the specified classss -c <host>
# Query the DNS name servers with the specified debugss -d <host>
# Query the DNS name servers with the specified filess -f <host>
# Query the DNS name servers with the specified interfacess -i <host>
# Query the DNS name servers with the specified keyss -k <host>
# Query the DNS name servers with the specified maxss -m <host>
# Query the DNS name servers with the specified numericss -n <host>
# Query the DNS name servers with the specified portss -p <host>
# Query the DNS name servers with the specified queryss -q <host>
# Query the DNS name servers with the specified recursess -r <host>
# Query the DNS name servers with the specified serverss -s <host>
# Query the DNS name servers with the specified typess -t <host>
# Query the DNS name servers with the specified verbosess -v <host>
# Query the DNS name servers with the specified versionss -V <host>
wget
The wget
command is used to query the DNS name servers. It takes no arguments. The output of the wget
command is the DNS name servers.
# Query the DNS name serverswget <host>
wget
Flags
-a
- Query the DNS name servers with the specified all.-b
- Query the DNS name servers with the specified bind.-c
- Query the DNS name servers with the specified class.-d
- Query the DNS name servers with the specified debug.-f
- Query the DNS name servers with the specified file.-i
- Query the DNS name servers with the specified interface.-k
- Query the DNS name servers with the specified key.-m
- Query the DNS name servers with the specified max.-n
- Query the DNS name servers with the specified numeric.-p
- Query the DNS name servers with the specified port.-q
- Query the DNS name servers with the specified query.-r
- Query the DNS name servers with the specified recurse.-s
- Query the DNS name servers with the specified server.-t
- Query the DNS name servers with the specified type.-v
- Query the DNS name servers with the specified verbose.-V
- Query the DNS name servers with the specified version.
# Query the DNS name servers with the specified allwget -a <host>
# Query the DNS name servers with the specified bindwget -b <host>
# Query the DNS name servers with the specified classwget -c <host>
# Query the DNS name servers with the specified debugwget -d <host>
# Query the DNS name servers with the specified filewget -f <host>
# Query the DNS name servers with the specified interfacewget -i <host>
# Query the DNS name servers with the specified keywget -k <host>
# Query the DNS name servers with the specified maxwget -m <host>
# Query the DNS name servers with the specified numericwget -n <host>
# Query the DNS name servers with the specified portwget -p <host>
# Query the DNS name servers with the specified querywget -q <host>
# Query the DNS name servers with the specified recursewget -r <host>
# Query the DNS name servers with the specified serverwget -s <host>
# Query the DNS name servers with the specified typewget -t <host>
# Query the DNS name servers with the specified verbosewget -v <host>
# Query the DNS name servers with the specified versionwget -V <host>
curl
The curl
command is used to query the DNS name servers. It takes no arguments. The output of the curl
command is the DNS name servers.
# Query the DNS name serverscurl <host>
curl
Flags
-a
- Query the DNS name servers with the specified all.-b
- Query the DNS name servers with the specified bind.-c
- Query the DNS name servers with the specified class.-d
- Query the DNS name servers with the specified debug.-f
- Query the DNS name servers with the specified file.-i
- Query the DNS name servers with the specified interface.-k
- Query the DNS name servers with the specified key.-m
- Query the DNS name servers with the specified max.-n
- Query the DNS name servers with the specified numeric.-p
- Query the DNS name servers with the specified port.-q
- Query the DNS name servers with the specified query.-r
- Query the DNS name servers with the specified recurse.-s
- Query the DNS name servers with the specified server.-t
- Query the DNS name servers with the specified type.-v
- Query the DNS name servers with the specified verbose.-V
- Query the DNS name servers with the specified version.
# Query the DNS name servers with the specified allcurl -a <host>
# Query the DNS name servers with the specified bindcurl -b <host>
# Query the DNS name servers with the specified classcurl -c <host>
# Query the DNS name servers with the specified debugcurl -d <host>
# Query the DNS name servers with the specified filecurl -f <host>
# Query the DNS name servers with the specified interfacecurl -i <host>
# Query the DNS name servers with the specified keycurl -k <host>
# Query the DNS name servers with the specified maxcurl -m <host>
# Query the DNS name servers with the specified numericcurl -n <host>
# Query the DNS name servers with the specified portcurl -p <host>
# Query the DNS name servers with the specified querycurl -q <host>
# Query the DNS name servers with the specified recursecurl -r <host>
# Query the DNS name servers with the specified servercurl -s <host>
# Query the DNS name servers with the specified typecurl -t <host>
# Query the DNS name servers with the specified verbosecurl -v <host>
# Query the DNS name servers with the specified versioncurl -V <host>
nmap
The nmap
command is used to query the DNS name servers. It takes no arguments. The output of the nmap
command is the DNS name servers.
# Query the DNS name serversnmap <host>
nmap
Flags
-A
- Query the DNS name servers with the specified all.-V
- Query the DNS name servers with the specified version.
# Query the DNS name servers with the specified allnmap -A <host>
# Query the DNS name servers with the specified versionnmap -V <host>
Manage System Processes
You may control Linux processes and troubleshoot any server resource-related issues with the use of these Linux commands. These commands let you keep an eye on your server’s RAM, CPU, disk IO, and other resources.
ps
The ps
command is used to list the processes running on the system. It takes no arguments. The output of the ps
command is the processes running on the system.
# List the processes running on the systemps
ps
Flags
-a
- List the processes running on the system with the specified all.-f
- List the processes running on the system with the specified full.-l
- List the processes running on the system with the specified long.-u
- List the processes running on the system with the specified user.
# List the processes running on the system with the specified allps -a
# List the processes running on the system with the specified fullps -f
# List the processes running on the system with the specified longps -l
# List the processes running on the system with the specified userps -u
top
The top
command is used to display the processes running on the system. It takes no arguments. The output of the top
command is the processes running on the system.
# Display the processes running on the systemtop
top
Flags
-b
- Display the processes running on the system with the specified batch.-c
- Display the processes running on the system with the specified command.-d
- Display the processes running on the system with the specified delay.-h
- Display the processes running on the system with the specified help.-i
- Display the processes running on the system with the specified idle.-n
- Display the processes running on the system with the specified iterations.-p
- Display the processes running on the system with the specified pid.-s
- Display the processes running on the system with the specified sort.-u
- Display the processes running on the system with the specified user.-v
- Display the processes running on the system with the specified version.
# Display the processes running on the system with the specified batchtop -b
# Display the processes running on the system with the specified commandtop -c
# Display the processes running on the system with the specified delaytop -d
# Display the processes running on the system with the specified helptop -h
# Display the processes running on the system with the specified idletop -i
# Display the processes running on the system with the specified iterationstop -n
# Display the processes running on the system with the specified pidtop -p
# Display the processes running on the system with the specified sorttop -s
# Display the processes running on the system with the specified usertop -u
# Display the processes running on the system with the specified versiontop -v
kill
The kill
command is used to kill a process. It takes one argument. The output of the kill
command is the killed process.
# Kill a processkill <pid>
kill
Flags
-l
- Kill a process with the specified list.
# Kill a process with the specified listkill -l <pid>
killall
The killall
command is used to kill a process. It takes one argument. The output of the killall
command is the killed process.
# Kill a processkillall <process>
killall
Flags
-l
- Kill a process with the specified list.
# Kill a process with the specified listkillall -l <process>
pkill
The pkill
command is used to kill a process. It takes one argument. The output of the pkill
command is the killed process.
# Kill a processpkill <process>
pkill
Flags
-l
- Kill a process with the specified list.
# Kill a process with the specified listpkill -l <process>
pgrep
The pgrep
command is used to kill a process. It takes one argument. The output of the pgrep
command is the killed process.
# Kill a processpgrep <process>
pgrep
Flags
-l
- Kill a process with the specified list.
# Kill a process with the specified listpgrep -l <process>
nice
The nice
command is used to run a process with a nice value. It takes one argument. The output of the nice
command is the process with a nice value.
# Run a process with a nice valuenice <process>
nice
Flags
-n
- Run a process with a nice value with the specified nice.-p
- Run a process with a nice value with the specified pid.-v
- Run a process with a nice value with the specified verbose.
# Run a process with a nice value with the specified nicenice -n <process>
# Run a process with a nice value with the specified pidnice -p <process>
# Run a process with a nice value with the specified verbosenice -v <process>
renice
The renice
command is used to run a process with a nice value. It takes one argument. The output of the renice
command is the process with a nice value.
# Run a process with a nice valuerenice <process>
renice
Flags
-n
- Run a process with a nice value with the specified nice.-p
- Run a process with a nice value with the specified pid.-v
- Run a process with a nice value with the specified verbose.
# Run a process with a nice value with the specified nicerenice -n <process>
# Run a process with a nice value with the specified pidrenice -p <process>
# Run a process with a nice value with the specified verboserenice -v <process>
at
The at
command is used to run a process at a specified time. It takes one argument. The output of the at
command is the process at a specified time.
# Run a process at a specified timeat <time>
at
Flags
-f
- Run a process at a specified time with the specified file.-q
- Run a process at a specified time with the specified queue.-r
- Run a process at a specified time with the specified remove.-v
- Run a process at a specified time with the specified verbose.
# Run a process at a specified time with the specified fileat -f <time>
# Run a process at a specified time with the specified queueat -q <time>
# Run a process at a specified time with the specified removeat -r <time>
# Run a process at a specified time with the specified verboseat -v <time>
atq
The atq
command is used to run a process at a specified time. It takes one argument. The output of the atq
command is the process at a specified time.
# Run a process at a specified timeatq <time>
atq
Flags
-c
- Run a process at a specified time with the specified clear.-q
- Run a process at a specified time with the specified queue.-v
- Run a process at a specified time with the specified verbose.
# Run a process at a specified time with the specified clearatq -c <time>
# Run a process at a specified time with the specified queueatq -q <time>
# Run a process at a specified time with the specified verboseatq -v <time>
atrm
The atrm
command is used to run a process at a specified time. It takes one argument. The output of the atrm
command is the process at a specified time.
# Run a process at a specified timeatrm <time>
atrm
Flags
-v
- Run a process at a specified time with the specified verbose.
# Run a process at a specified time with the specified verboseatrm -v <time>
batch
The batch
command is used to run a process at a specified time. It takes one argument. The output of the batch
command is the process at a specified time.
# Run a process at a specified timebatch <time>
batch
Flags
-f
- Run a process at a specified time with the specified file.-q
- Run a process at a specified time with the specified queue.-r
- Run a process at a specified time with the specified remove.-v
- Run a process at a specified time with the specified verbose.
# Run a process at a specified time with the specified filebatch -f <time>
# Run a process at a specified time with the specified queuebatch -q <time>
# Run a process at a specified time with the specified removebatch -r <time>
# Run a process at a specified time with the specified verbosebatch -v <time>
crontab
The crontab
command is used to run a process at a specified time. It takes one argument. The output of the crontab
command is the process at a specified time.
# Run a process at a specified timecrontab <time>
crontab
Flags
-e
- Run a process at a specified time with the specified edit.-l
- Run a process at a specified time with the specified list.-r
- Run a process at a specified time with the specified remove.
# Run a process at a specified time with the specified editcrontab -e <time>
# Run a process at a specified time with the specified listcrontab -l <time>
# Run a process at a specified time with the specified removecrontab -r <time>
iostat
The iostat
command is used to run a process at a specified time. It takes one argument. The output of the iostat
command is the process at a specified time.
# Run a process at a specified timeiostat <time>
iostat
Flags
-c
- Run a process at a specified time with the specified count.-d
- Run a process at a specified time with the specified device.-h
- Run a process at a specified time with the specified help.-k
- Run a process at a specified time with the specified kilobytes.-m
- Run a process at a specified time with the specified megabytes.-p
- Run a process at a specified time with the specified partition.-q
- Run a process at a specified time with the specified quiet.-t
- Run a process at a specified time with the specified time.-x
- Run a process at a specified time with the specified extended.-y
- Run a process at a specified time with the specified summary.
# Run a process at a specified time with the specified countiostat -c <time>
# Run a process at a specified time with the specified deviceiostat -d <time>
# Run a process at a specified time with the specified helpiostat -h <time>
# Run a process at a specified time with the specified kilobytesiostat -k <time>
# Run a process at a specified time with the specified megabytesiostat -m <time>
# Run a process at a specified time with the specified partitioniostat -p <time>
# Run a process at a specified time with the specified quietiostat -q <time>
# Run a process at a specified time with the specified timeiostat -t <time>
# Run a process at a specified time with the specified extendediostat -x <time>
# Run a process at a specified time with the specified summaryiostat -y <time>
vmstat
The vmstat
command is used to run a process at a specified time. It takes one argument. The output of the vmstat
command is the process at a specified time.
# Run a process at a specified timevmstat <time>
vmstat
Flags
-a
- Run a process at a specified time with the specified all.-d
- Run a process at a specified time with the specified disk.-f
- Run a process at a specified time with the specified file.-h
- Run a process at a specified time with the specified help.-i
- Run a process at a specified time with the specified interrupt.
# Run a process at a specified time with the specified allvmstat -a <time>
# Run a process at a specified time with the specified diskvmstat -d <time>
# Run a process at a specified time with the specified filevmstat -f <time>
# Run a process at a specified time with the specified helpvmstat -h <time>
# Run a process at a specified time with the specified interruptvmstat -i <time>
sar
The sar
command is used to run a process at a specified time. It takes one argument. The output of the sar
command is the process at a specified time.
# Run a process at a specified timesar <time>
sar
Flags
-A
- Run a process at a specified time with the specified all.-B
- Run a process at a specified time with the specified block.-b
- Run a process at a specified time with the specified boot.-d
- Run a process at a specified time with the specified device.-e
- Run a process at a specified time with the specified error.-f
- Run a process at a specified time with the specified file.-h
- Run a process at a specified time with the specified help.-H
- Run a process at a specified time with the specified huge.-I
- Run a process at a specified time with the specified interrupt.-j
- Run a process at a specified time with the specified job.-k
- Run a process at a specified time with the specified kernel.-l
- Run a process at a specified time with the specified lock.-m
- Run a process at a specified time with the specified memory.-n
- Run a process at a specified time with the specified network.-o
- Run a process at a specified time with the specified output.-p
- Run a process at a specified time with the specified partition.-q
- Run a process at a specified time with the specified queue.-r
- Run a process at a specified time with the specified remove.-R
- Run a process at a specified time with the specified reboot.-S
- Run a process at a specified time with the specified swap.-s
- Run a process at a specified time with the specified system.-t
- Run a process at a specified time with the specified time.-u
- Run a process at a specified time with the specified user.-v
- Run a process at a specified time with the specified version.-w
- Run a process at a specified time with the specified wait.-W
- Run a process at a specified time with the specified watchdog.-x
- Run a process at a specified time with the specified extended.-y
- Run a process at a specified time with the specified summary.
# Run a process at a specified time with the specified allsar -A <time>
# Run a process at a specified time with the specified blocksar -B <time>
# Run a process at a specified time with the specified bootsar -b <time>
# Run a process at a specified time with the specified devicesar -d <time>
# Run a process at a specified time with the specified errorsar -e <time>
# Run a process at a specified time with the specified filesar -f <time>
# Run a process at a specified time with the specified helpsar -h <time>
# Run a process at a specified time with the specified hugesar -H <time>
# Run a process at a specified time with the specified interruptsar -I <time>
# Run a process at a specified time with the specified jobsar -j <time>
# Run a process at a specified time with the specified kernelsar -k <time>
# Run a process at a specified time with the specified locksar -l <time>
# Run a process at a specified time with the specified memorysar -m <time>
# Run a process at a specified time with the specified networksar -n <time>
# Run a process at a specified time with the specified outputsar -o <time>
# Run a process at a specified time with the specified partitionsar -p <time>
# Run a process at a specified time with the specified queuesar -q <time>
# Run a process at a specified time with the specified removesar -r <time>
# Run a process at a specified time with the specified rebootsar -R <time>
# Run a process at a specified time with the specified swapsar -S <time>
# Run a process at a specified time with the specified systemsar -s <time>
# Run a process at a specified time with the specified timesar -t <time>
# Run a process at a specified time with the specified usersar -u <time>
# Run a process at a specified time with the specified versionsar -v <time>
# Run a process at a specified time with the specified waitsar -w <time>
# Run a process at a specified time with the specified watchdogsar -W <time>
# Run a process at a specified time with the specified extendedsar -x <time>
# Run a process at a specified time with the specified summarysar -y <time>
Summary
You learnt about Linux CLI commands in this tutorial, along with the fundamental commands for:
- File Management
- Finding files and directories
- Check User Information
- Managing Users and Groups
- Managing Permissions
- Check System Information
- Configure and Troubleshoot Network
- Manage System Processes