File and Directory Operations
ls
: List files and subdirectories in the current directorycd
: change the current working directorypwd
: Display the path of the current working directorymkdir
: create a new directoryrm
: Delete files or empty directoriescp
: Copy a file or the entire directory tree to the specified locationmv
: move or rename files and directories
text editor
nano
: Open and edit the text file with the Nano text editor.- Example:
$ nano filename.txt
- Example:
File viewing and searching
cat
: View single or multiple file contents and output them to the terminal.- Example:
$ cat filename.txt
- Example:
Note : If you want to view large text files on the terminal, it is recommended to use a pager program such as 'less'.
System Information Query
Note : The following commands require administrator privileges (sudo) to execute.
CPU-related information query:
-
Query the CPU model:
$ lscpu | grep "Model name"
-
Query the number of CPU cores:
$ lscpu | grep "Core(s) per socket"
-
Query the number of CPU threads:
$ lscpu | grep "Thread(s) per core"
-
Query the total number of logical processors (number of threads * number of cores * number of physical sockets):
$ lscpu | grep "CPU(s)"
Memory-related information query:
- Query memory usage:
$ free -h
Disk space query:
- Query disk space usage (by file system):
$ df -h
network operation
-
ping
: Send ICMP ECHO_REQUEST packets to the target host to test network connectivity and latency.- Example:
$ ping example.com
- Example:
-
ifconfig
: View and configure the IP address, subnet mask and other information of the network interface, but it has been discarded in newer versions of Linux. It is recommended to useip
commands instead.