Basic Linux Command
Basic Linux Command
Commands
What is linux? What is terminal? What is a Linux Command?
Linux is an Open-Source Terminal is just a mechanism to transfer A Linux command is a program or utility that runs on
Operating System based on Unix. information. For the operating system the CLI – a console that interacts with the system via
Linux was first introduced by to understand the information, a shell is texts and processes. It’s similar to the Command
Linus Torvalds. The main needed. A shell in Linux is a program Prompt application in Windows.Linux commands
purpose of Linux was to provide that interprets the commands you enter are executed on Terminal by pressing Enter at the
in a terminal window, so the operating end of the line. You can run commands to perform
free and low-cost Operating
system can understand what you want
System for users who could not various tasks, from package installation to user
to do.
afford Operating Systems like management and file manipulation.
Windows or iOS or Unix.
Basic Linux Commands
Short for superuser do, sudo is one of the most popular basic Linux commands that lets you perform tasks that require administrative or root
permissions.
sudo Here’s the general syntax:
sudo (command)
The switch user or su command allows you to run a program as a different user. It changes the administrative account in the current log-in
session. This command is especially beneficial for accessing the system through SSH or using the GUI display manager when the root user is
unavailable.
su Here’s the general syntax of the command:
su [options] [username [argument]]
Use the pwd command to find the path of your current working directory. Simply entering pwd will return the full current path – a path of all the
pwd directories that starts with a forward slash (/). For example, /home/username.
The pwd command uses the following syntax:
pwd [option]
To navigate through the Linux files and directories, use the cd command. Depending on your current working directory, it requires either the full pa
cd the directory name.
The ls command lists files and directories within a system. Running it without a flag or parameter will show the current working directory’s
ls content.
cp Use the cp command to copy files or directories and their content. Take a look at the following use cases.
mv The primary use of the mv command is to move and rename files and directories. Additionally, it doesn’t produce an output upon execution.
Use the mkdir command to create one or multiple directories at once and set permissions for each of them. The user executing this command
must have the privilege to make a new folder in the parent directory, or they may receive a permission denied error.
mkdir Here’s the basic syntax:
mkdir [option] directory_name
To permanently delete an empty directory, use the rmdir command. Remember that the user running this command should have sudo
rmdir privileges in the parent directory.
touch The touch command allows you to create an empty file or generate and modify a timestamp in the Linux command line.
rm The rm command is used to delete files within a directory. Make sure that the user performing this command has write permissions.
cat Concatenate, or cat, is one of the most frequently used Linux commands. It lists, combines, and writes file content to the standard output.
locate The locate command can find a file in the database system.
Use the find command to search for files within a specific directory and perform subsequent operations.
find Here’s the general syntax:
find [option] [path] [expression]
Another basic Linux command on the list is grep or global regular expression print. It lets you find a word by searching through all the texts in a
grep specific file.
chmod is a common command that modifies a file or directory’s read, write, and execute permissions. In Linux, each file is associated with
three user classes – owner, group member, and others.
chmod Here’s the basic syntax:
chmod [option] [permission] [file_name]
apt-get is a command line tool for handling Advanced Package Tool (APT) libraries in Linux. It lets you retrieve information and bundles from
apt-get authenticated sources to manage, update, remove, and install software and its dependencies.
Here’s the main syntax:
apt-get [options] (command)
The tar command archives multiple files into a TAR file – a common Linux format similar to ZIP, with optional compression
tar Here’s the basic syntax:
tar [options] [archive_file] [file or directory to be archived]
The uname or unix name command will print detailed information about your Linux system and hardware. This includes the machine name,
uname operating system, and kernel. To run this command, simply enter uname into your CLI.
Here’s the basic syntax:
uname [option]
usradd Linux is a multi-user system, meaning more than one person can use it simultaneously. useradd is used to create a new account, while the
usrdel passwd command allows you to add a password. Only those with root privileges or sudo can run the useradd command.
zip Use the zip command to compress your files into a ZIP file, a universal format commonly used on Linux. It can automatically choose the best
unzip compression ratio.
The man command provides a user manual of any commands or utilities you can run in Terminal, including the name, description, and
man options.
With history, the system will list up to 500 previously executed commands, allowing you to reuse them without re-entering. Keep in mind
that only users with sudo privileges can execute this command. How this utility runs also depends on which Linux shell you use.
history To run it, enter the command below:
history [option]
The echo command is a built-in utility that displays a line of text or string using the standard output.
echo Here’s the basic syntax:
echo [option] [string]
ifconfig ifconfig stands for "interface configuration." It is used to view and change the configuration of the network interfaces on your system.
Run the hostname command to know the system’s hostname. You can execute it with or without an option.
hostname Here’s the general syntax:
hostname [option]
The ping command is one of the most used basic Linux commands for checking whether a network or a server is reachable. In addition, it is
used to troubleshoot various connectivity issues.
ping Here’s the general format:
ping [option] [hostname_or_IP_address]
The Linux command line lets you download files from the internet using the wget command. It works in the background without hindering
other running processes.
wget To use it, enter the following command:
wget [option] [url]
In computing, traceroute and tracert are computer network diagnostic commands for displaying possible routes and measuring transit
traceroute delays of packets across an Internet Protocol network