Table of Contents
This updated overview organizes the essential information about Basic Linux Commands Everyone Needs to Know - Operations on Linux, including practical uses, key features, setup considerations, and common questions.
What This Guide Covers
- 1. Some important notes about Linux Terminal
- [sudo] command [optional switch] [file or directory path]
- 2. Get familiar with your account
Just like the Windows operating system, when using Linux you should also learn basic Linux commands to perform operations more quickly and easily. Below are some basic Linux commands you should know.
With some of the commands below, you will see sets of commands with simple explanations, specific illustrative examples to help you or the Linux users you are supporting use this operating system in general, and the command line above. Linux in particular is more efficient.
1. Some important notes about Linux Terminal

To quickly open Terminal from the GUI, press the key combination Ctrl + Alt + T .
Dissecting most Linux commands:
[sudo] command [optional switch] [file or directory path]
Using sudo will run any command under Admin. Most Linux commands are used to install/remove a program's system files, using something that requires sudo.
2. Get familiar with your account
These commands will help new Linux users get acquainted with their Linux account.
| Command | Function | For example |
|---|---|---|
| pwd | Displays the current location in the file system. | pwd |
| whoami | Show username - most useful if switching users with the su command and need to be reminded of which account is in use | whoami |
| ls | Provides a file list. With the -a parameter , the command displays files whose names begin with a period (for example, .bashrc). With the -l parameter , the command displays permissions, file size and last updated date/time. | ls ls -a ls -l |
| env | Shows user environment settings (e.g. search path, saved history size, home directory, etc.) | env |
| echo. echo | Echoes user-supplied text or displays the value of some variable. | echo hello echo $PATH |
| history. history | Lists previously issued commands. | history history | tail -5 |
| passwd | Change the password. Note that complex requirements may be enforced. | passwd history | tail -5 |
3. Create a new folder
mkdir is a basic directory manipulation command on Linux, helping you create a new directory quickly. Command syntax:
mkdir folder
Note:
Folder is the name of the folder you want to create. For example, if you want to create a folder named backup, the syntax is:
mkdir /home/marin/backup
In case if you want to create a folder containing many subfolders, you can use the "-p" option . Suppose, you have the directory foo and have access to it:
mkdir -p /foo/bar/baz
The above command will create the bar directory, the baz directory is located in bar; bar and baz are in /foo already.
4. Search the current directory
If you want to search your current directory, you can use the pwd command.
The pwd command in Linux stands for present working directory. When it comes to Linux commands, this is one of the simplest. Its only function is to export the current working directory in the terminal. It comes in handy when you're not sure exactly what directory you're in, or when you need to move the current working directory inside a Bash script, for example.
Eg:
marin@[LinuxVeda]:[~/work]$ pwd /home/marin/work
You can change directories using the cd command or list the contents of the current directory using the ls command.
You can use this command to help determine your current location in the directory structure. It is also a very useful command to use in scripts where you may not know the exact directory structure of where the script is running.
This command is usually built-in as a shell builtin in most modern shells such as bash, zsh, and ksh. System administrators mainly use the command because regular users don't need it.
The pwd command itself is extremely simple and does not require any additional flags or parameters. The standard syntax of the command is as follows.
pwd [option]…
To display the current working directory using pwd's default behavior, simply enter the following line in the command prompt.
pwd
The pwd command accepts two different flags.
- -L will print the path even if it includes symbolic links.
- -P Will print the physical path, avoiding symbolic links.
It is important to note that the behavior of pwd is slightly different from the /bin/pwd command.
5. Create and edit files
Linux systems provide commands to create files. The user can select the desired text editor. Some commands require users to be proficient before using them, while others are quite simple.
| Command | Function | For example |
|---|---|---|
| nano | An easy-to-use text editor that requires the user to move around in the file using arrow keys and provides control sequences to position text, save changes, etc. | nano myfile |
| Because | A more sophisticated editor, allowing users to enter commands to find and change text, make global changes, etc. | vi myfile |
| ex | A text editor designed for programmers and has both visual and command-line modes. | ex myfile |
| touch | Create a file if it does not exist yet or update the timestamp if it has been created. | touch newfile touch updatedfile |
| > | Create files by directing output to them. > creates a file while >> attaching to an existing file. | cal > calendar ps > myprocs date >> date.log |
6. Read some files
Usually you have to review the contents of many different files. Regularly reviewing different files is often quite complicated and time-consuming. Therefore the simplest way to read their contents is to use the cat command. The command syntax is quite simple:
cat FILE
Just change FILE with the file name you want to read. As a result, you will see the content of the file appear at the bottom of Terminal.
Eg:
cat script.sh

Additionally, you can use the cat command for multiple files at once:
cat FILE-1 FILE-2
The output of the command will display the contents of the files in the order of the contents of FILE - 1 and then the contents of FILE -2.
Additionally, Linux provides a number of commands to review the content and nature of files. Here are some of the most useful commands.
| Command | Function | For example |
|---|---|---|
| cat | Displays the entire content of a text file. | cat .bashrc |
| more | Displays the content of the text file. Press the spacebar to move to each additional paragraph. | more .bash_history |
| less. less | Displays the contents of the text file, but allows you to return using the up arrow key. | less .bash_history |
| file | Identify files by type (e.g. ASCII text, executable files, images, folders) | file myfile file ~/.bashrc file /bin/echo |
7. Copy or move files
Copying or moving files in the Linux terminal is quite simple and easy.
- To copy a file, you can use the command: cp.
- To move a file, use the command: mvoflder.
Both commands are quite simple to use. With the cp command . To copy a file, enter a file name and enter a new copy file name. For example:
cp file1 file2
The above command copies file1 and creates file2 containing the contents of file1. You can use cp to copy directories. It is important to note that when you want to copy a directory you should use the -r option .
In other words, cp -r will copy the contents of a given directory (and subdirectories) to the directory of your choice. Also you can use cp with full path:
cp -r /home/marin/work/ /home/marin/backup
The above command will copy the contents of the "work" folder to a new folder named "backup".
If you want to copy all files and folders of one folder to another folder, you can use the "*" character . The character is used to find suitable ports (in this case, files and directories). For example:
cp /home/marin/work/* /home/marin/backup/
Next is the mv command. Command syntax:
mv file1 file2
The above command changes file1 to file2. The same goes for folders. However, if you specify 1 file and 1 folder, the file will be moved into the folder. Such as:
mv /home/marin/file1 /home/marin/work/
The above command will move file1 from '/home/marin/' to '/home/marin/work/'. If you want to move all files in one folder to another folder, you can use the "*" character :
mv /home/marin/work/* /home/marin/backup/
8. Delete files and folders
If you want to delete a folder or a file, you can use the rm command . It is important to note that when using this command to delete a file or folder, these files cannot be restored. To delete a file, do:
rm /home/marin/useless-file.txt
You can use rm with many different options. Some important options include:
- -f: force deletion of files with reminder messages
- -i: prompt before deletion
- -r: delete directories recursively
- -d: delete empty directories
- -v: explains what task is being performed
9. Find files
There are two commands that can help users find files on Linux, but they work very differently. One command searches the file system, while the other looks at a previously built database.
| Command |
Function |
For example |
|---|---|---|
| find.find | Locate files based on provided criteria (name, type, owner, permissions, file size, etc.). Unless a location is given to start the search, this command searches only in the current directory. | find . -name myfile find /tmp -type d |
| locate. locate | Locate files using the contents of /var/lib/mlocate/mlocate.db updated by the updateb command run via cron. No starting position required. | locate somefile locate "*.html" -n 20 |
Note: Details about the find command are in the section below.
10. List directory contents
To list directories, you can use the ls command :

The "ls" command can take different parameters that help you change the output of the command. For example, the "-a" parameter will display all files and folders, including hidden folders containing "-a".

If you want the command output to display a detailed list of information for each file and directory, you can use the '-l' (L) option :
ls -l You can try different

Additionally, you can combine parameters to display detailed information for all files:
ls –al

11. Search for the previous Linux command
Pressing the Up key will display the last Linux command you used successfully. There are no error statements displayed here.
Additionally, you can use the history command to view all Linux commands ever used on Terminal.
12. Invisible password

When asked to enter a password, let's say in the case of using sudo , when you type the password on the screen nothing will be displayed, no stars or dots. After entering the password, you Press Enter and you're done.
13. Copy and paste Linux commands

To copy or paste Terminal commands, you cannot use the familiar key combinations Ctrl + C and Ctrl + V.
Instead you can use Ctrl + Shift + C and Ctrl + Shift + V or right-click and select Copy or Paste from the Context Menu.
14. Display progress in Linux system
# ps aux | less
Hình 1: Thông tin tiến trình đang chạy trong hệ thống.
15. Kiểm tra thông tin Socket và thông tin mạng TCP/UDP
- Mọi Socket TCP.
- Mọi Socket UDP.
- Mọi kết nối ssh/ftp/http/https.
- Mọi Socket TCP trong trạng thái FIN-WAIT-1.
- # ss –s : Hiển thị tổng số Socket.
Hình 2: Thông tin kết xuất khi chạy lệnh # ss –s.
- # ss -1 : Hiển thị mọi cổng mở.
Hình 3: Thông tin kết xuất khi chạy lệnh # ss -1.
- # ss -lp | grep : Kiểm tra người dùng đang làm việc với Socket mở.
- # ss -t –a : Hiển thị mọi Socket TCP.
- # ss -u –a : Hiển thị mọi Socket UDP.
16. Theo dõi Average CPU Load và Disk Activity
Khi chạy lệnh isostat thông tin kết xuất có dạng:
Hình 4: Thông tin hiển thị khi chạy lệnh isostat.
# iostat –n
17. Kiểm tra Memory Map của các tiến trình trong Linux
Hình 5: Thông tin hiển thị sau khi chạy lệnh free
18. Kiểm tra thời gian vận hành của hệ thống
Hình 6: Kết quả lệnh uptime.
19. Kiểm tra người dùng đăng nhập
# w username
Hình 7: Thông tin hiển thị sau khi chạy lệnh # w username.
20. Kiểm soát hành vi hệ thống, phần cứng và thông tin hệ thống trong Linux
Bạn chỉ cần nhập lệnh sau vào cửa sổ terminal:
# vmstat 3
Hình 8: Thông tin kết xuất của lệnh # vmstat 3.
Hình 9: Thông tin hiển thị sau khi chạy lệnh # vmstat –a.
21. Kiểm tra thông tin phần cứng của hệ thống Linux
# hdparm -I /dev/sda
Hoặc dùng lệnh:
$ sudo hdparm -I /dev/sda
Khi đó thông tin về đĩa cứng của hệ thống sẽ lập tức hiển thị.
Hình 10: Thông tin chi tiết của đĩa cứng.
22. Các lệnh xử lý tập tin trên Linux
Lệnh để di chuyển xung quanh hệ thống file Linux là ls, nhưng có nhiều biến thể.
| Lệnh Linux | Nhiệm vụ lệnh sẽ làm |
| ls | Liệt kê nội dung thư mục hiện tại |
| ls -al | Liệt kê nội dung thư mục bao gồm cả file ẩn |
| cd dir | Di chuyển từ thư mục hiện tại sang thư mục dir |
| cd | Chuyển từ thư mục hiện tại về thư mục riêng (thường là [Tên User] ở Home) |
| cd . | Di chuyển lên (về /) một thư mục từ vị trí hiện tại. |
| cd |
cd /tmp cd Documents cd ~/Documents |
| pwd | Hiện thư mục hiện tại |
| mkdir TipsMake | Tạo thư mục mới có tên là TipsMake |
| rm filemuonxoa | Xóa file có tên là filemuonxoa |
| rm -r thumuccanxoa | Xóa thư mục có tên là TipsMake |
| rm -f filecanxoa | Bắt xóa file có tên là filecanxoa |
| rm -rf thumuccanxoa | Bắt xóa thư mục có tên là thumuccanxoa |
| cp file1 file2 | Sao chép file1 sang file2 |
| cp -r dir1 dir2 | Sao chép thư mục dir1 sang dir2 và tạo dir2 nếu chưa có dir2 |
| mv file1 file2 | Di chuyển file1 đến chỗ file2 hoặc đổi tên file1 thành file2. Nếu file2 có sẵn thì di chuyển file1 vào file2 |
| ln -s tenfile link | Tạo liên kết biểu tượng có tên là link đến file có tên là tenfile |
| touch filecantao | Tạo hoặc cập nhật tập tin filecantao |
| cat > tenfile | Nhập từ bàn phím (đầu vào chuẩn - standard input) vào tập tin tenfile mới |
| more tenfile | Hiện nội dung file có tên là tenfile |
| head tenfile | Hiện 10 dòng đầu của tập tin tenfile |
| tail tenfile | Hiện 10 dòng cuối của tập tin tenfile |
| tail -f tenfile | Hiện nội dung của tập tin tenfile và cập nhật liên tục trong thời gian thực |
| tail -f -n N tenfile | Hiện nội dung của tập tin tenfile và cập nhật liên tục, giới hạn N dòng |
23. Các lệnh mạng trên Linux
24. Bắt đầu, dừng và liệt kê các service
Các lệnh này cho phép người dùng hiển thị các service cũng như bắt đầu và dừng chúng.
| Lệnh | Chức năng | Ví dụ |
|---|---|---|
| systemctl | Lệnh systemctl có thể bắt đầu, dừng, khởi động lại và load lại các service, cần có quyền admin. | sudo systemctl stop apache2.service sudo systemctl restart apache2.service sudo systemctl reload apache2.service |
| service | Liệt kê các service và cho biết liệu chúng có đang chạy không. | service --status-all |
25. Xác định phiên bản hệ điều hành
Bảng bên dưới liệt kê các lệnh sẽ hiển thị chi tiết về hệ điều hành Linux đang chạy trên hệ thống.
| Lệnh | Chức năng | Ví dụ |
|---|---|---|
| uname | Hiển thị thông tin về phiên bản hệ điều hành trong một dòng văn bản. | uname -a uname -r |
| lsb_release | Trên các hệ thống dựa trên Debian, lệnh này hiển thị thông tin về hệ điều hành bao gồm codename và ID nhà phân phối. | lsb_release -a |
| hostnamectl | Hiển thị thông tin trên hệ thống bao gồm tên máy chủ, loại chassis (thùng máy), hệ điều hành, kernel và cấu trúc. | hostnamectl |
26. Đo hiệu suất hệ thống
| Lệnh | Chức năng | Ví dụ |
|---|---|---|
| top | Hiển thị các tiến trình đang chạy cùng với việc sử dụng tài nguyên và dữ liệu hiệu suất hệ thống. Có thể hiển thị các tiến trình cho một người dùng đã chọn hoặc tất cả người dùng. Các tiến trình có thể được sắp xếp theo các tiêu chí khác nhau (theo mặc định là mức độ sử dụng CPU). | top top jdoe |
| atop | Tương tự như lệnh trên nhưng hướng nhiều đến hiệu năng hệ thống hơn so với các tiến trình riêng lẻ. | atop |
| free | Hiển thị bộ nhớ và trao đổi tổng bộ nhớ, phần đã sử dụng và còn trống. | free |
| df | Hiển thị việc sử dụng không gian ổ đĩa hệ thống của file. | df df -h |
27. Quản lý người dùng và nhóm
| Lệnh | Chức năng | Ví dụ |
|---|---|---|
| useradd | Thêm tài khoản người dùng mới vào hệ thống. Tên người dùng là bắt buộc. Các trường khác (mô tả người dùng, shell, mật khẩu ban đầu, v.v.) có thể được chỉ định. Thư mục chính sẽ mặc định là /home/username. | useradd -c "John Doe" jdoe useradd -c "Jane Doe" -g admin -s /bin/bash jbdoe |
| userdel | Xóa tài khoản người dùng khỏi hệ thống. Tùy chọn -f mạnh mẽ hơn, xóa các file chính và file người dùng khác ngay cả khi người dùng vẫn đăng nhập. | userdel jbdoe userdel -f jbdoe |
| groupadd | Thêm một nhóm người dùng mới vào hệ thống, cập nhật /etc/group . | groupadd developers |
| groupdel | Xóa nhóm người dùng khỏi hệ thống. | groupdel developers |
28. Thiết lập và chạy các tiến trình theo lịch
| Lệnh | Chức năng | Ví dụ |
|---|---|---|
| crontab | Thiết lập và quản lý các tiến trình theo lịch. Với tùy chọn -l, các công việc định kỳ được liệt kê. Với tùy chọn -e, các công việc định kỳ có thể được thiết lập để chạy ở các khoảng thời gian đã chọn. | crontab -l crontab -l -u username crontab -e |
| anacron | Cho phép người dùng chỉ chạy các công việc theo lịch trình hàng ngày. Nếu hệ thống bị tắt khi một công việc được đặt lịch chạy, nó sẽ chạy khi hệ thống khởi động. | sudo vi /etc/anacrontab |
29. Cập nhật, cài đặt và liệt kê các ứng dụng
| Lệnh | Chức năng | Ví dụ |
|---|---|---|
| apt update | Trên các hệ thống dựa trên Debian, lệnh này cập nhật danh sách các gói có sẵn và các phiên bản của chúng, nhưng không cài đặt hoặc nâng cấp bất kỳ gói nào | sudo apt update |
| apt upgrade | Trên các hệ thống dựa trên Debian, lệnh này cài đặt các phiên bản mới hơn của các gói đã có. | sudo apt upgrade |
| apt list | Liệt kê tất cả các gói được cài đặt trên hệ thống dựa trên Debian. Với tùy chọn --upgradable, nó chỉ hiển thị các gói có bản nâng cấp. | apt list apt list --installed apt list --upgradable |
| apt install | Trên các hệ thống dựa trên Debian, lệnh này cài đặt gói được yêu cầu. | sudo apt install apache2 |
| yum update | Trên các hệ thống dựa trên RPM, lệnh này cập nhật tất cả hoặc các gói được chỉ định. | sudo yum update yum update mysql |
| yum list | Trên các hệ thống dựa trên RPM, lệnh này liệt kê các gói. | sudo yum update mysql |
| yum install | Trên các hệ thống dựa trên RPM, lệnh này cài đặt gói được yêu cầu. | sudo yum -y install firefox |
| yum list | Trên các hệ thống dựa trên RPM, lệnh này liệt kê các gói đã biết và đã cài đặt. | sudo yum list sudo yum list --installed |
30. Tắt và khởi động lại
| Lệnh | Chức năng | Ví dụ |
|---|---|---|
| shutdown | Tắt hệ thống tại thời điểm yêu cầu. Tùy chọn -H tạm dừng hệ thống, còn tùy chọn -P sẽ tắt nguồn. | sudo shutdown -H now shutdown -H +15 shutdown -P +5 |
| halt | Tắt hệ thống tại thời điểm yêu cầu. | sudo halt sudo halt -p sudo halt --reboot |
| poweroff | Ngắt nguồn khỏi hệ thống tại thời điểm yêu cầu. | sudo shutdown -H now sudo shutdown -H +15 sudo shutdown -P +5 |
31. Lệnh bảo mật Linux
Final Thoughts
Use the instructions and checks above in order, verify the result after each major step, and keep a backup whenever the process changes important files or system settings.
FAQ
What is Linux, Linux commands used for?
Just like the Windows operating system, when using Linux you should also learn basic Linux commands to perform operations more quickly and easily.
Who should consider Linux, Linux commands?
It is most useful for readers who need the features, workflow, or problem-solving approach described in this guide.
What should I check before using it?
Review compatibility, current software requirements, privacy or security settings, costs, and any limitations that could affect your workflow.
Reader Comments 0
Sign in with email or Google to join the discussion.