echo
uname -m : Display the processor architecture of the machine
uname -r : Display the kernel version being used
dmidecode -q : Display hardware system components
cat /proc/cpuinfo : Display CPU info information
cat /proc/interrupts : Display interrupts
cat /proc /meminfo : Displays memory usage
cat /proc/swaps : Displays which swaps are used
cat /proc/version : Displays the version of the kernel
cat /proc/net/dev : Displays network adapters and statistics
cat /proc/mounts : Displays loaded filesystem
date : Displays the system date
cal 2021 : display the calendar for 2021
shutdown
shutdown -h now : Shut down the system
init 0 : Shut down the system
telinit 0 : Shut down the system
shutdown -h hours:minutes & : Shut down the system at the scheduled time
shutdown -c : Cancel the shutdown at the scheduled time
shutdown -r now : Restart
reboot : Restart
logout : logout
files and directories
cd /home : enter the "/home" directory
cd .. return to the previous directory
cd ../.. return to the previous two-level directorycd
- return to the last directory
pwd : display the working path
ls : view the files in the directory
ls -F : View files in a directory
ls -l : Display details of files and directories
ls -a : Display hidden files
ls [0-9] : Display file names and directory names containing numbers
tree : Display files and directories by root directory start tree
lstree : show files and directories start tree
mkdir dir1 : create a directory called 'dir1'
mkdir dir1 dir2 : create two directories at the same time
mkdir -p /tmp/dir1/dir2 : Create a directory tree
touch file1 : create file1 file
rm -f file1 : delete a file called "file1"
rmdir dir1 : delete a directory called "dir1"
rm -rf dir1: delete a directory called "dir1" and delete its contents at the same time
rm -rf dir1 dir2 : delete two directories and their contents at the same time
mv dir1 new_dir : rename/move a directory
cp file1 file2 : copy a file
cp dir/* .Copy all files in a directory to the current working directory
cp -a /tmp/dir1 .Copy a directory to the current working directory
cp -a dir1 dir2 : Copy a directory
ln -s file1 lnk1 : Create a soft link
ln file1 lnk1 : Creates a physical link to a file or directory
file search
find / -name file1 : start from "/" to enter the root file system to search for files and directories
find / -user user1 : search for files and directories belonging to user "user1"
find /home/user1 -name *.bin : in the directory "/ search for files ending with '.bin' in home/user1"
find /usr/bin -type f -atime +100 : search for executable files that have not been used in the last 100 days
find /usr/bin -type f -mtime -10 : search for files that were created or modified within 10 days
locate *.ps : look for files ending in ".ps" - run the "updatedb" command first
whereis halt : show the location of a binary, source or man
which halt : Displays the full path to a binary or executable
disk space
df -h : Display the list of mounted partitions
ls -lSr |more : Arrange files and directories by size
du -sh dir1 : Estimate the disk space used by directory "dir1"'
du -sk * | sort -rn : sort by Display the size of files and directories in sequence based on the size of the capacity
users and groups
groupadd group_name : create a new user group
groupdel group_name : delete a user group
groupmod -n new_group_name old_group_name : rename a user group
useradd -c "Name Surname " -g admin -d /home/user1 -s /bin/bash user1 : Create a user belonging to the "admin" usergroup
useradd user1 : create a new user
userdel -r user1 : delete a user ("-r" excludes the home directory)
usermod -c "User FTP" -g system -d /ftp/user1 -s /bin/nologin user1 : Modify user attributes
passwd : Modify password
passwd user1 : Modify a user's password (only root execution is allowed)
pwck : Check the file format and syntax correction of "/etc/passwd" and existing users
grpck : Check "/etc/passwd" for file format and syntax corrections and existing groups
file permissions
ls -lh : Display permissions
chmod ugo+rwx directory1 : Set the permissions of owner (u), group (g) and others (o) of the directory to read (r), write (w) and execute (x) permissions
chmod go-rwx directory1 : delete group (g) and others (o) read and write permissions to the directory
chown user1 file1 : change the owner attribute of a file
chown -R user1 directory1 : change the owner attribute of a directory and at the same time Change the attributes of all files in the directory
chgrp group1 file1 : change the group of the file
chown user1:group1 file1 : change the owner and group attributes of a file
Pack and compress files
gunzip file1.gz : decompress a file called 'file1.gz'
gzip file1 : compress a file called 'file1'
gzip -9 file1 : maximize compression
tar -cvf archive.tar file1 : create an uncompressed tarball
tar - cvf archive.tar file1 file2 dir1 : create an archive containing 'file1', 'file2' and 'dir1'
tar -tf archive.tar : display the contents of a package
tar -xvf archive.tar : release a package
tar -xvf archive.tar -C /tmp : release the compressed package to the /tmp directory
tar -cvfj archive.tar.bz2 dir1 : create a compressed package in bzip2 format
tar -jxvf archive.tar.bz2 : decompress a compressed package in bzip2 format Compression package
tar -cvfz archive.tar.gz dir1 : create a compressed package in gzip format
tar -zxvf archive.tar.gz : decompress a compressed package in gzip format
zip file1.zip file1 : create a compressed package in zip format
zip -r file1.zip file1 file2 dir1 : Compress several files and directories into a compressed package in zip format at the same time
unzip file1.zip : Unzip a compressed package in zip format
view file content
cat file1 : view the content of a file forward from the first byte
tac file1 : view the content of a file in reverse from the last line
more file1 : view the content of a long file
less file1 : similar to the "more" command, but It allows the same reverse operation as the forward operation in the file
head -2 file1 : view the first two lines of a file
tail -2 file1 : view the last two lines of a file
tail -f /var/log/messages : view the messages in real time content to add to a file
Query port occupancy and kill the process that occupies the port
1) Check the port occupied by the known program name
Check the process ID: ps -ef|grep the program name (such as tomcat)
According to the result of the previous step, check the occupied port: netstat -nap I grep pid(109)
2) Know which one is occupied Port, check the program name
Check the process ID: netstat -nap Igrep port (8080)
According to the result of the previous step, check the application name: ps -ef| grep pid