Table of Contents
Basic Linux Commands and Examples for Newbies
1. View the Contents of a Directory
2. Viewing Blocks, HDD Partition, External HDD
3. Checking the Integrity of Downloaded/Transferred Packages
4. Converting and Copying a File
5. Know Your Machine Name, OS, and Kernel
6. Viewing History of Commands
7. Run Commands as Root User
8. Make a New Directory
9. Create or Update File Timestamps
10. Changing the File Permission
11. Change File Ownership
12. Install, Update, and Maintain Packages
13. Uncompressing a Tar File
14. See Current Date, Time, and Calendar
15. Print Contents of a File
16. Copy and Move Files
17. See the Working Directory for Easy Navigation
18. Change the Working Directory
Advanced Linux Commands for Intermediate Users
19. Finding a File in a Given Directory
20. Searching a File with the Given Keywords
21. Finding Online Documentation
22. List Current Running Processes
23. Kill a Running Process
24. See the Location of Installed Binaries
25. Starting, Ending, Restarting a Service
26. Creating and Removing Command Aliases
27. View Disk and Space Usage
28. Removing a File and/or Directory
29. Print/Echo a Custom Output on Standard Output
30. Changing Password in Linux
31. View Printing Queue
32. Compare Two Files
33. Download a File, the Linux Way (wget)
34. Mount a Block/Partition/External HDD
35. Compile and Run C, C , and Java Code
Advance Linux Commands for Linux Sysadmins
36. Configuring Network Interface
37. Viewing Custom Network-Related Information
38. Fetching Data with curl
39. Checking DNS Information
40. Knowing Your System Uptime
41. Broadcast Messages to Logged-in Users
42. Send Text Messages Directly to a User
43. Piping Commands Together
44. Seeing the Processes of a CPU
45. Creating a Newly Formatted ext4 Partition
46. Editing Files with vi, emacs, and nano
47. Copying a Large File/Folder with Progress Bar
48. Check Available Memory
49. Backing Up a MySQL Database
50. Generate a Random Password
51. Merge Two Text Files
52. List of All the Opened Files
Home System Tutorial LINUX 50 Essential Linux Commands for Beginners and SysAdmins

50 Essential Linux Commands for Beginners and SysAdmins

May 07, 2025 am 11:12 AM

50 Essential Linux Commands for Beginners and SysAdmins

For someone new to Linux, using it can still feel challenging, even with user-friendly distributions like Ubuntu and Mint.

While these distributions simplify many tasks, some manual configuration is often required, but fully harnessing the power of Linux, understanding basic commands is essential.

In Linux, commands are the primary way to interact with the system and allow users to perform tasks, configure settings, and manage the system efficiently.

This guide introduces 60 essential Linux commands, providing a foundation for beginners and a pathway to becoming a skilled system administrator. These commands cover a wide range of functions, from navigating directories and managing files to performing advanced system operations.

Whether you’re just starting out or aiming to deepen your expertise, these commands will help you unlock the full potential of Linux.

Basic Linux Commands and Examples for Newbies

Whether you’re a beginner or an advanced user, mastering basic Linux commands is essential for navigating and controlling the operating system.

Below are some commonly used Linux commands along with their descriptions and examples:

1. View the Contents of a Directory

The ls command is used to view the files and directories within a specified directory, it can display both visible and hidden files (files starting with . are hidden by default).

Additional options can provide detailed information like file permissions, ownership, size, and modification dates.

ls -la
Copy after login

2. Viewing Blocks, HDD Partition, External HDD

The lsblk command displays information about block devices such as hard drives, partitions, and external drives in a tree-like format.

lsblk
Copy after login

3. Checking the Integrity of Downloaded/Transferred Packages

The sha256sum or md5sum commands generate and verify cryptographic hash values for files, which ensures the file’s integrity after downloading or transferring.

sha256sum file.tar.gz
Copy after login

4. Converting and Copying a File

The dd command is used for low-level file copying and conversion, which is often employed to create bootable USB drives or clone disk images.

dd if=input.img of=output.img bs=4M status=progress
Copy after login

5. Know Your Machine Name, OS, and Kernel

The uname command provides system information, including the kernel version, system architecture, and hostname.

uname -a
Copy after login

6. Viewing History of Commands

The history command lists previously executed commands, allowing you to recall or reuse them.

history
Copy after login

7. Run Commands as Root User

The sudo command allows users to execute commands with administrative privileges. Use sudo -i to switch to a root shell.

sudo -i
Copy after login

8. Make a New Directory

The mkdir command creates a new directory with the specified name in the current location.

mkdir my_folder
Copy after login

9. Create or Update File Timestamps

The touch command creates empty files or updates the timestamp of existing ones.

touch my_file.txt
Copy after login

10. Changing the File Permission

The chmod command changes file permissions, controlling who can read, write, or execute a file.

chmod 644 my_file.txt
Copy after login

11. Change File Ownership

The chown command changes file ownership and group ownership.

sudo chown user:group my_file.txt
Copy after login

12. Install, Update, and Maintain Packages

The apt command manages software packages on Debian-based systems.

sudo apt update && sudo apt install package_name
Copy after login

13. Uncompressing a Tar File

The tar command extracts compressed files.

tar -xvzf file.tar.gz
Copy after login

14. See Current Date, Time, and Calendar

The date and cal commands display the current date, time, and calendar.

date
cal
Copy after login

The cat command prints the contents of a file to the terminal.

cat my_file.txt
Copy after login

16. Copy and Move Files

The cp and mv commands copy and move files, respectively.

cp source.txt destination.txt
mv old_name.txt new_name.txt
Copy after login

17. See the Working Directory for Easy Navigation

The pwd command prints the current directory path.

pwd
Copy after login

18. Change the Working Directory

The cd command navigates between directories.

cd /path/to/directory
Copy after login

Advanced Linux Commands for Intermediate Users

Once you’ve mastered the basic Linux commands, it’s time to dive deeper into more advanced commands that will help you manage and optimize your system more efficiently.

19. Finding a File in a Given Directory

The find command is used to search for files and directories within a specified directory or across the entire file system.

find /path/to/directory -name "filename"
Copy after login

20. Searching a File with the Given Keywords

The grep command is used to search for specific patterns (keywords) within files, which is highly useful when you want to find specific information inside a file or a set of files.

grep "keyword" filename
Copy after login

21. Finding Online Documentation

The man command displays the manual or help documentation for a specific command, which provides detailed information about how to use a command, its options, and its syntax.

man ls
Copy after login

22. List Current Running Processes

The ps command shows a snapshot of the current processes running on your system with details like process IDs (PIDs), memory usage, and CPU usage.

ps aux
Copy after login

To list all processes related to Firefox, using grep to filter the output.

ps aux | grep firefox
Copy after login
Copy after login

23. Kill a Running Process

The kill command is used to terminate a running process by specifying the process ID (PID) of the process you want to terminate.

kill 1234
Copy after login

24. See the Location of Installed Binaries

The which command helps locate the path of executables in your system’s PATH by searching through the directories listed in the PATH environment variable and returns the location of the executable.

which python3
Copy after login

25. Starting, Ending, Restarting a Service

The systemctl command is used to manage system services (also known as daemons) on systems using systemd.

systemctl start service_name
systemctl stop service_name
systemctl restart service_name
Copy after login

26. Creating and Removing Command Aliases

Aliases are shortcuts for commands, which can save time by reducing the amount of typing and the alias command creates a shortcut, while unalias remove it.

alias shortcut_name='command'
unalias shortcut_name
Copy after login

You can create an alias for a command with a custom name.

alias ll='ls -l'
unalias ll
Copy after login

This creates an alias ll for the ls -l command, which lists directory contents in a long format.

27. View Disk and Space Usage

The df command shows disk space usage for all mounted file systems by providing information about the total space, used space, and available space.

df -h
Copy after login

28. Removing a File and/or Directory

The rm command is used to remove files and directories. You can use the -r option to remove directories and their contents recursively.

rm filename
rm -r directory_name
Copy after login

The echo command is used to print text or the value of a variable to the terminal.

echo "Custom Message"
Copy after login

30. Changing Password in Linux

The passwd command is used to change passwords for the current user or other users (if you are the root user).

passwd username
Copy after login

31. View Printing Queue

The lpq command shows the status of the printing queue, including any pending or completed print jobs.

lpq
Copy after login

32. Compare Two Files

The diff command compares two files line by line and displays the differences between them.

diff file1 file2
Copy after login

33. Download a File, the Linux Way (wget)

The wget command is used to download files from the internet, it supports HTTP, HTTPS, and FTP protocols.

wget https://example.com/file.zip
Copy after login

34. Mount a Block/Partition/External HDD

The mount command is used to attach a block device (e.g., a hard drive or USB drive) to a directory in the filesystem.

mount /dev/sdX /mnt
Copy after login

35. Compile and Run C, C , and Java Code

To compile and run code in C, C , and Java, you use the respective compilers and runtimes.

  • C: gcc is used to compile C programs.c.
  • C : g is used to compile C programs.
  • Java: javac is used to compile Java programs, and java is used to run them.

To compile and run C code:

gcc -o outputfile sourcefile.c
./outputfile
Copy after login

To compile and run C code:

g   -o outputfile sourcefile.cpp
./outputfile
Copy after login

To compile and run Java code:

javac filename.java
java filename
Copy after login

Advance Linux Commands for Linux Sysadmins

In the last section of this series, we tried to cover the commands that needed to administer a Linux server.

36. Configuring Network Interface

The ifconfig command is used to allow you to set up, manage, and display network interface parameters, which is typically used to assign IP addresses, configure network interfaces, and troubleshoot network issues.

sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0 up
Copy after login

This command assigns the IP address 192.168.1.100 to the eth0 interface and brings it up.

The netstat command provides detailed information about network connections, routing tables, interface statistics, and more.

netstat -tuln
Copy after login

38. Fetching Data with curl

The curl command is used to transfer data from or to a server. It supports various protocols, including HTTP, FTP, and more. You can use it to fetch data from a web server or test server responses.

curl -I https://www.example.com
Copy after login

39. Checking DNS Information

The dig command is a DNS lookup utility that provides detailed information about DNS records, which is commonly used for troubleshooting DNS issues.

dig example.com
Copy after login

40. Knowing Your System Uptime

The uptime command shows how long the system has been running, the number of users logged in, and the system load averages for the past 1, 5, and 15 minutes.

uptime
Copy after login

41. Broadcast Messages to Logged-in Users

The wall command is used to send messages to all users currently logged into the system.

echo "System Maintenance in 10 minutes" | wall
Copy after login

42. Send Text Messages Directly to a User

The write command allows you to send a message to another logged-in user.

write username
Copy after login

43. Piping Commands Together

You can combine multiple commands using pipes (|) to pass the output of one command to another.

ps aux | grep firefox
Copy after login
Copy after login

44. Seeing the Processes of a CPU

The top command displays a dynamic, real-time view of system processes, including CPU and memory usage.

top
Copy after login

45. Creating a Newly Formatted ext4 Partition

The mkfs.ext4 command is used to create an ext4 file system on a partition.

sudo mkfs.ext4 /dev/sdb1
Copy after login

46. Editing Files with vi, emacs, and nano

In Linux, there are several text editors available for editing files directly from the command line. Among the most popular are vi, emacs, and nano.

To edit files with vi:

vi filename.txt
Copy after login

To edit files with emacs:

emacs myfile.txt
Copy after login

To edit files with nano:

nano myfile.txt
Copy after login

47. Copying a Large File/Folder with Progress Bar

The rsync command is used to copy files and directories. With the --progress option, it shows a progress bar.

rsync -avh --progress source_directory/ destination_directory/
Copy after login

48. Check Available Memory

The free command shows the amount of free and used memory in the system.

free -h
Copy after login

49. Backing Up a MySQL Database

The mysqldump command is used to create backups of MySQL databases.

mysqldump -u root -p database_name > backup.sql
Copy after login

50. Generate a Random Password

The openssl command can generate a random password.

openssl rand -base64 12
Copy after login

51. Merge Two Text Files

The cat command can be used to concatenate two text files into one.

cat file1.txt file2.txt > mergedfile.txt
Copy after login

52. List of All the Opened Files

The lsof command lists all open files and the processes that opened them.

lsof
Copy after login

These commands are fundamental tools for system administrators and users to interact with Linux systems efficiently.

The above is the detailed content of 50 Essential Linux Commands for Beginners and SysAdmins. 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

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.

Undress AI Tool

Undress AI Tool

Undress images for free

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

Java Tutorial
1664
14
PHP Tutorial
1267
29
C# Tutorial
1239
24
What is the most use of Linux? What is the most use of Linux? Apr 09, 2025 am 12:02 AM

Linux is widely used in servers, embedded systems and desktop environments. 1) In the server field, Linux has become an ideal choice for hosting websites, databases and applications due to its stability and security. 2) In embedded systems, Linux is popular for its high customization and efficiency. 3) In the desktop environment, Linux provides a variety of desktop environments to meet the needs of different users.

How to learn Linux basics? How to learn Linux basics? Apr 10, 2025 am 09:32 AM

The methods for basic Linux learning from scratch include: 1. Understand the file system and command line interface, 2. Master basic commands such as ls, cd, mkdir, 3. Learn file operations, such as creating and editing files, 4. Explore advanced usage such as pipelines and grep commands, 5. Master debugging skills and performance optimization, 6. Continuously improve skills through practice and exploration.

Does the internet run on Linux? Does the internet run on Linux? Apr 14, 2025 am 12:03 AM

The Internet does not rely on a single operating system, but Linux plays an important role in it. Linux is widely used in servers and network devices and is popular for its stability, security and scalability.

What are Linux operations? What are Linux operations? Apr 13, 2025 am 12:20 AM

The core of the Linux operating system is its command line interface, which can perform various operations through the command line. 1. File and directory operations use ls, cd, mkdir, rm and other commands to manage files and directories. 2. User and permission management ensures system security and resource allocation through useradd, passwd, chmod and other commands. 3. Process management uses ps, kill and other commands to monitor and control system processes. 4. Network operations include ping, ifconfig, ssh and other commands to configure and manage network connections. 5. System monitoring and maintenance use commands such as top, df, du to understand the system's operating status and resource usage.

What is the salary of Linux administrator? What is the salary of Linux administrator? Apr 17, 2025 am 12:24 AM

The average annual salary of Linux administrators is $75,000 to $95,000 in the United States and €40,000 to €60,000 in Europe. To increase salary, you can: 1. Continuously learn new technologies, such as cloud computing and container technology; 2. Accumulate project experience and establish Portfolio; 3. Establish a professional network and expand your network.

What are the main tasks of a Linux system administrator? What are the main tasks of a Linux system administrator? Apr 19, 2025 am 12:23 AM

The main tasks of Linux system administrators include system monitoring and performance tuning, user management, software package management, security management and backup, troubleshooting and resolution, performance optimization and best practices. 1. Use top, htop and other tools to monitor system performance and tune it. 2. Manage user accounts and permissions through useradd commands and other commands. 3. Use apt and yum to manage software packages to ensure system updates and security. 4. Configure a firewall, monitor logs, and perform data backup to ensure system security. 5. Troubleshoot and resolve through log analysis and tool use. 6. Optimize kernel parameters and application configuration, and follow best practices to improve system performance and stability.

Boost Productivity with Custom Command Shortcuts Using Linux Aliases Boost Productivity with Custom Command Shortcuts Using Linux Aliases Apr 12, 2025 am 11:43 AM

Introduction Linux is a powerful operating system favored by developers, system administrators, and power users due to its flexibility and efficiency. However, frequently using long and complex commands can be tedious and er

What is the main purpose of Linux? What is the main purpose of Linux? Apr 16, 2025 am 12:19 AM

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

See all articles