国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
Linux File System Commands
1. cat Command
2. cp Command
3. ls Command
4. mkdir Command
5. history Command
6. du Command
7. stat Command
Linux Networking Commands
8. ping Command
9. host Command
10. whois Command
Linux System Information Commands
11. uptime Command
12. free Command
13. lsblk Command
Home System Tutorial LINUX Most Commonly Used Linux Commands You Should Know

Most Commonly Used Linux Commands You Should Know

Jun 28, 2025 am 10:53 AM

Linux is a very popular Operating System (OS) amongst programmers and regular users. One of the main reasons for its popularity is its exceptional command line support. We can manage the entire Linux operating system via command line interface (CLI) only. This allows us to accomplish complex tasks with a just few commands.

In this guide, we will discuss some commonly used commands that are useful for experienced sysadmin or a beginner. After following this guide, users will be able to operate the Linux system confidently.

For better organization, these commands are grouped under three sections – file system, networking, and system information.

Linux File System Commands

In this section, we will discuss some of the useful commands related to files and directories in Linux.

1. cat Command

The cat command is mainly used to display the file contents. It reads the content of the file and displays them on the standard output (stdout).

The common syntax of the cat command is:

$ cat [OPTIONS] [FILE1] [FILE2] ...

Let’s display the contents of the /etc/os-release file using the cat command:

$ cat /etc/os-release

Most Commonly Used Linux Commands You Should Know

Additionally, we can also use the -n option of the command to display the contents with the line number:

$ cat -n /etc/os-release

Most Commonly Used Linux Commands You Should Know

2. cp Command

The cp command is useful for copying files, groups of files, and directories.

The common syntax of the cp command is:

$ cp [OPTIONS]  

Here, the square brackets ([]) represent the optional arguments whereas angular brackets () represent the essential arguments.

Let’s copy the /etc/os-release file to the /tmp directory:

$ cp /etc/os-release /tmp/new-file.txt

Now, let’s display the contents of the file to verify the file has been copied:

$ cat /tmp/new-file.txt

Most Commonly Used Linux Commands You Should Know

Similarly, we can copy the directory using the cp command. Let’s copy the /etc/cron.d directory inside the /tmp directory:

$ cp -r /etc/cron.d /tmp

We have used the -r option with the cp command, which represents the recursive operation. It copies the directory recursively which includes its files and sub-directories.

In the next example, we will see how to verify that the directory has been copied successfully.

$ ls /tmp/cron.d
$ ls -l /tmp/cron.d

Most Commonly Used Linux Commands You Should Know

3. ls Command

The ls command is used to list the directory contents and sort files by size and last modified time in descending order.

The common syntax of the ls command is:

$ ls [OPTIONS] [FILE1] [FILE2] ...

If we don’t provide any argument to the ls command then it lists the contents of the current directory.

$ ls

Most Commonly Used Linux Commands You Should Know

In the previous example, we copied the /etc/cron.d directory to the /tmp directory. Let’s verify that is present there and contains the required files:

$ ls /tmp/cron.d

We can use the -l option with the ls command to display more detailed information like – file permissions, owner, timestamp, size, etc.

Let’s find out more details about the files present in the /tmp/cron.d directory:

$ ls -l /tmp/cron.d

Most Commonly Used Linux Commands You Should Know

4. mkdir Command

We often create a directory structure to organize the contents. In Linux, we can use the mkdir command to create a directory or multiple directories and set the correct permissions for the directories.

The common syntax of the mkdir command is:

$ mkdir [OPTIONS] <directory1> <directory2> ...
</directory2></directory1>

Let’s create a directory with the name dir-1 in the /tmp directory:

$ mkdir /tmp/dir-1

Now, let’s verify that the directory has been created:

$ ls /tmp/dir-1

Here, we can see that the ls command doesn’t report any error which means the directory is present there.

Sometimes, we need to create a nested directory structure for better data organization. In such cases, we can use the -p option of the command to create a few nested directories under the /tmp/dir-1 directory:

$ mkdir -p /tmp/dir-1/dir-2/dir-3/dir-4/dir-5

In the above example, we have created 4 levels of the nested directories. Let’s confirm it using the ls command:

$ ls -R /tmp/dir-1

Here, we have used the -R option with the command to display the directory contents in a recursive way.

Most Commonly Used Linux Commands You Should Know

5. history Command

To audit the last executed commands, you can use the history command, which displays the list of last executed commands in a terminal session.

$ history

Most Commonly Used Linux Commands You Should Know

To view the command history with a time stamp, you need to set the timestamp in bash history, run:

$ HISTTIMEFORMAT="%d/%m/%y %T "             #Temporarily set the history timestamp
$ export HISTTIMEFORMAT="%d/%m/%y %T "      #Permanently set the history timestamp
$ history

Most Commonly Used Linux Commands You Should Know

6. du Command

How will you check the top 10 files that are eating out your disk space? A simple one-liner script made from the du command, which is primarily used for file space usage.

$ du -hsx * | sort -rh | head -10

Most Commonly Used Linux Commands You Should Know

Explanation of above du command options and switches.

  • du – Estimate file space usage.
  • -hsx(-h) Human Readable Format, (-s) Summaries Output, (-x) One File Format, skip directories on other file formats.
  • sort – Sort text file lines.
  • -rh(-r) Reverse the result of the comparison, (-h) to compare the human-readable format.
  • head – output first n lines of file.

7. stat Command

The stat command is used to get the information about the file size, access permission, access time, and the user ID and group ID of the file.

$ stat anaconda-ks.cfg

Most Commonly Used Linux Commands You Should Know

Linux Networking Commands

In this section, we will discuss some of the networking commands that beginners can use to troubleshoot network-related issues.

8. ping Command

One of the very common operations performed in any network is to check if a particular host is reachable or not. We can use the ping command to check the connectivity with the other host.

The general syntax of the ping command is:

$ ping [OPTIONS] <destination>
</destination>

Here, the destination can be an IP address or a Fully Qualified Domain Name (FQDN) such as google.com. Let’s verify that the current system can communicate with google:

$ ping -c 4 google.com

Most Commonly Used Linux Commands You Should Know

In the above example, the command shows the statistics about network communication, which shows that the response is received for all four network requests (packets). It is important to note that, we have used the -c option with the command to limit the number of requests to be sent to the particular host.

Let’s see the example when the communication between the two hosts is broken.

To simulate this scenario, we will try to reach a non-reachable IP address. In this case, it is 192.168.10.100:

$ ping -c 4 192.168.10.100

Most Commonly Used Linux Commands You Should Know

Here, we can see that we didn’t receive a response for any network request. Hence the command reports the error – Destination Host Unreachable.

9. host Command

Sometimes, we need to find the IP address of the particular domain. To achieve this, we can use the host command, which performs a DNS lookup and translates FQDN to IP address and vice-versa.

The general syntax of the host command is:

$ host [OPTIONS] <destination>
</destination>

Here, the destination can be an IP address or FQDN.

Let’s find out the IP address of google.com using the host command:

$ host google.com

Most Commonly Used Linux Commands You Should Know

10. whois Command

All the details about the registered domains are stored in the centralized database and can be queried using the whois command, which shows details about the particular domain.

The general syntax of the whois command is:

$ whois [OPTIONS] <fqdn>
</fqdn>

Let’s find out details of the google.com:

$ whois google.com

Most Commonly Used Linux Commands You Should Know

Here, we can see much detailed information like – domain registration/renew/expiration date, domain provider, and so on.

It is important to note that, the whois command is not available by default on all systems. However, we can install it using the package manager. For example, on Debian-based distributions we can install it using the apt package manager:

$ sudo apt install whois

On RHEL-based and other distributions, you can install it as shown.

$ sudo yum install whois         [On <strong>RHEL/CentOS/Fedora</strong> and <strong>Rocky Linux/AlmaLinux</strong>]
$ sudo emerge -a net-misc/whois  [On <strong>Gentoo Linux</strong>]
$ sudo apk add whois             [On <strong>Alpine Linux</strong>]
$ sudo pacman -S whois           [On <strong>Arch Linux</strong>]
$ sudo zypper install whois      [On <strong>OpenSUSE</strong>]    

Linux System Information Commands

In this section, we will discuss some of the commands that can provide details about the current system.

11. uptime Command

It’s a very common requirement to find when the system was rebooted last time using the uptime command, which tells how long the system has been running.

Let’s find out the uptime of the current system:

$ uptime -p

<strong>12:10:57 up  2:00,  1 user,  load average: 0.48, 0.60, 0.45</strong>

In this example, we have used the -p option to show the output in the pretty form.

12. free Command

Users often need to find the details about the installed, available, and used memory. This information plays an important role while troubleshooting performance issues. We can use the free command to find the details about the memory:

$ free -m

Here, we have used the -m option with the command which shows the output in the mebibytes.

Most Commonly Used Linux Commands You Should Know

In a similar way, we can the -g, -t, and -p options to show the output in the gibibytes, tebibytes, and pebibytes respectively.

13. lsblk Command

Computer systems store data on block devices. Examples of block devices are Hard Disk Drives (HDD), Solid State Drives (SSD), and so on. We can use the lsblk command to display detailed information about the block devices:

$ lsblk

In this example, we can see that there is only one block device and its name is /dev/sda. There are three partitions created on that block device.

Most Commonly Used Linux Commands You Should Know

In this article, we discussed some of the commands that are useful for Linux beginners. First, we discussed the file system commands. Then we discussed networking commands. Finally, we discussed some commands that provided details about the current system.

The above is the detailed content of Most Commonly Used Linux Commands You Should Know. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1502
276
How to troubleshoot DNS issues on a Linux machine? How to troubleshoot DNS issues on a Linux machine? Jul 07, 2025 am 12:35 AM

When encountering DNS problems, first check the /etc/resolv.conf file to see if the correct nameserver is configured; secondly, you can manually add public DNS such as 8.8.8.8 for testing; then use nslookup and dig commands to verify whether DNS resolution is normal. If these tools are not installed, you can first install the dnsutils or bind-utils package; then check the systemd-resolved service status and configuration file /etc/systemd/resolved.conf, and set DNS and FallbackDNS as needed and restart the service; finally check the network interface status and firewall rules, confirm that port 53 is not

Install Guacamole for Remote Linux/Windows Access in Ubuntu Install Guacamole for Remote Linux/Windows Access in Ubuntu Jul 08, 2025 am 09:58 AM

As a system administrator, you may find yourself (today or in the future) working in an environment where Windows and Linux coexist. It is no secret that some big companies prefer (or have to) run some of their production services in Windows boxes an

How to Install NodeJS 14 / 16 & NPM on Rocky Linux 8 How to Install NodeJS 14 / 16 & NPM on Rocky Linux 8 Jul 13, 2025 am 09:09 AM

Built on Chrome’s V8 engine, Node.JS is an open-source, event-driven JavaScript runtime environment crafted for building scalable applications and backend APIs. NodeJS is known for being lightweight and efficient due to its non-blocking I/O model and

How to find my private and public IP address in Linux? How to find my private and public IP address in Linux? Jul 09, 2025 am 12:37 AM

In Linux systems, 1. Use ipa or hostname-I command to view private IP; 2. Use curlifconfig.me or curlipinfo.io/ip to obtain public IP; 3. The desktop version can view private IP through system settings, and the browser can access specific websites to view public IP; 4. Common commands can be set as aliases for quick call. These methods are simple and practical, suitable for IP viewing needs in different scenarios.

System requirements to install linux System requirements to install linux Jul 20, 2025 am 03:49 AM

Linuxcanrunonmodesthardwarewithspecificminimumrequirements.A1GHzprocessor(x86orx86_64)isneeded,withadual-coreCPUrecommended.RAMshouldbeatleast512MBforcommand-lineuseor2GBfordesktopenvironments.Diskspacerequiresaminimumof5–10GB,though25GBisbetterforad

How to Install MySQL 8.0 on Rocky Linux and AlmaLinux How to Install MySQL 8.0 on Rocky Linux and AlmaLinux Jul 12, 2025 am 09:21 AM

Written in C, MySQL is an open-source, cross-platform, and one of the most widely used Relational Database Management Systems (RDMS). It’s an integral part of the LAMP stack and is a popular database management system in web hosting, data analytics,

Ubuntu 25.04 'Plucky Puffin”: A Bold Leap Forward with GNOME 48 and HDR Brilliance Ubuntu 25.04 'Plucky Puffin”: A Bold Leap Forward with GNOME 48 and HDR Brilliance Jul 12, 2025 am 09:28 AM

Ubuntu has long stood as a bastion of accessibility, polish, and power in the Linux ecosystem. With the arrival of Ubuntu 25.04, codenamed “Plucky Puffin”, Canonical has once again demonstrated its commitment to delivering a

How to Install MongoDB on Rocky Linux and AlmaLinux How to Install MongoDB on Rocky Linux and AlmaLinux Jul 12, 2025 am 09:29 AM

MongoDB is a high-performance, highly scalable document-oriented NoSQL database built to manage heavy traffic and vast amounts of data. Unlike traditional SQL databases that store data in rows and columns within tables, MongoDB structures data in a J

See all articles