Basics Commands of Linux
Basics Commands of Linux
Hosting
VPS
Email
Domain
Log In
WordPressVPSWebsite DevelopmenteCommerceWebsite ErrorsHow to
Make a Website
search
VPS
Feb 22, 2024
Valentinas C. & Aris S.
21min Read
60 Essential Linux
Commands + Free Cheat
Sheet
To manage a Linux remote machine like a virtual private server (VPS),
system administrators commonly use a command-line interface (CLI).
While some Linux distributions offer a graphical user interface (GUI),
commands are more efficient and flexible with a CLI.
For example, you can replace specific entries in multiple files using a
single command, which takes time in a GUI. However, using bash shell
can be tricky since Linux has many commands for various tasks.
To help you get started, we will explore 60 essential Linux commands
for VPS management. You will also learn tips for using a CLI and
leveraging Hostinger’s VPS AI Assistant to easily generate Linux
commands.
o The 60 Most Commonly Used Linux Commands
o Linux Commands Tips and Tricks
o Make the Most Out of Your Linux With VPS AI
Assistant
o Linux Commands FAQ
rm Deletes a file
uname Prints information about your machine’s kernel, name, and hardware
netstat Shows the system’s network information, like routing and sockets
alias and unalias Sets and removes an alias for a file or command
1. ls command
The ls command lists files and directories in your system. Here’s the
syntax:
ls [/directory/folder/path]
If you remove the path, the ls command will show the current working
directory’s content. You can modify the command using these options:
2. pwd command
The pwd command prints your current working directory’s path,
like /home/directory/path. Here’s the command syntax:
pwd [option]
It supports two options. The -L or –-logical option prints environment
variable content, including symbolic links. Meanwhile, -P or –
physical outputs the current directory’s actual path.
3. cd command
Use the cd command to navigate the Linux files and directories. To use
it, run this syntax with sudo privileges:
cd /directory/folder/path
Depending on your current location, it requires either the full path or the
directory name. For example,
omit /username from /username/directory/folder if you are already
within it.
Omitting the arguments will take you to the home folder. Here are some
navigation shortcuts:
4. mkdir command
Use the mkdir command to create one or multiple directories and set
their permissions. Ensure you are authorized to make a new folder in
the parent directory. Here’s the basic syntax:
mkdir [option] [directory_name]
To create a folder within a directory, use the path as the command
parameter. For example, mkdir music/songs will create a songs folder
inside music. Here are several common mkdir command options:
5. rmdir command
Use the rmdir command to delete an empty directory in Linux. The
user must have sudo privileges in the parent directory. Here’s the
syntax:
rmdir [option] directory_name
If the folder contains a subdirectory, the command will return an error.
To force delete a non-empty directory, use the -p option.
6. rm command
Use the rm command to permanently delete files within a directory.
Here’s the general syntax:
rm [filename1] [filename2] [filename3]
Adjust the number of files in the command according to your needs. If
you encounter an error, ensure you have the write permission in the
directory.
To modify the command, add the following options:
7. cp command
Use the cp command to copy files or directories, including their content,
from your current location to another. It has various use cases, such as:
8. mv command
Use the mv command to move or rename files and directories. To move
items, enter the file name followed by the destination directory:
mv filename.txt /home/username/Documents
Meanwhile, use the following syntax to rename a file in Linux with
the mv command:
mv old_filename.txt new_filename.txt
9. touch command
The touch command lets you create an empty file in a specific directory
path. Here’s the syntax:
touch [option] /home/directory/path/file.txt
If you omit the path, the command will create the item in the current
folder. You can also use touch to generate and modify a timestamp in
the Linux command line.
If you omit the path, the command will search the current working
directory. You can also find directories using the following:
find ./ -type d -name directoryname
Linux Commands for User and Permission Management
Below are several Linux commands for managing the system’s users
and permissions.
27. su command
The su command lets you run a program in the Linux shell as a different
user. It is useful to connect via SSH while the root user is disabled.
Here’s the syntax:
su [options] [username [argument]]
Without any option or argument, this command runs through root and
prompts you to use the sudo privileges temporarily. Some options are:
31. df command
Use the df command to check a Linux system’s disk space usage in
percentage and kilobyte (KB). Here’s the syntax:
df [options] [file]
If you don’t specify the item, this command will display information about
every mounted file system. These are some acceptable options:
32. du command
Use du to check a file or directory’s storage consumption. Remember to
specify the directory path when using this command, for example:
du /home/user/Documents
The du command has several options, such as:
Suggested Reading
Learn more about using top, htop, and ps commands to check running
processes in a Linux system.
57. ln command
The ln command lets you create links between files or directories to
simplify system management. Here’s the syntax:
ln [option] [source] [destination]
The command will create the target file or directory and link it to the
source. By default, it creates a hard link, meaning the new item
connects to the same data block as the source.
Expert Tip
Did you know that you can edit a text file with Linux commands using
SSH? Instead of editing a file locally and uploading it via FTP, you can
edit the file instantly on your account using the vim or nano command.
Paulius M.
Web Hosting Monitoring Tech Lead
Conclusion
Linux commands make system administrative tasks more efficient. They
provide users with greater flexibility and the ability to use features that a
graphical user interface may not offer.
Understanding how to use Linux commands in VPS is essential for
interaction and management. They generally consist of three parts –
a command name, a flag or option, and a parameter or argument.
This article has discussed various Linux commands for different tasks,
such as apt-get to install a package, nano to manipulate text files,
and htop to monitor current processes. To run them, use Terminal, an
SSH client, or Hostinger’s Browser terminal.
Other Useful Linux Commands to Learn
How to Configure and Manage Ubuntu Firewall with the UFW
Command
How to Install and Use the Linux Screen Command
How to List Users in Ubuntu with Linux Commands
How to Change Password in Linux
Linux Commands FAQ
In this section, we will answer several questions about Linux commands
to help you understand more about them.
How to List All Linux Commands?
Use compgen -c, help, or man -k . to list all available Linux commands
in your system. To check a command usage and its options, use –help.
For example, enter apt –help to check the available options for
the apt command.
How Do I Open Terminal in Linux?
In a GUI-based Linux, Terminal is located in the Utility menu or
accessible using the Ctrl + Alt + T shortcut. For Linux servers, Terminal
is opened by default after you log in to the system.
What Does the Syntax Command -option
Argument Mean?
It is the typical order of a command-line utility in Unix-like operating
systems like Linux. Command refers to the program you want to run,
and -option modifies its behavior. Meanwhile, an argument is the input
data the utility is operating on.
What Do […] and <…> Mean in Command
Usage?
In Linux command syntax, both […] and <…> enclose placeholders.
While […] is used for an optional parameter, <…> is for required
components. For example, options are enclosed in square brackets,
and input files are in angular ones.
Why Am I Getting a “Permission Denied”
Error?
Permission denied means the command
requires root or superuser privilege to run. To gain the privilege,
add sudo at the beginning of each command or switch to the superuser
using sudo su. If the error is related to files or directories, change their
permissions using the chmod command.
What Do I Do if a Command Is “not
found”?
If the command you enter is correct, the not found error message
means the utility isn’t installed in your Linux system. To fix it, install the
command using your system’s package manager, like apt for Debian
and dnf for RHEL.