File and directory operations

The command parsing
cd /home Go to the ‘/home’ directory
cd .. Returns the upper directory
cd .. /.. Returns the last two levels of directories
cd – Returns the last directory
cp file1 file2 Copy file1 to file2
cp -a dir1 dir2 Copy a directory
cp -a /tmp/dir1 . Copy a directory to the current working directory (. Represents the current directory)
ls View the files in the directory
ls -a Show hidden files
ls -l Display details
ls -lrt Display files by time (L for detailed list, R for reverse sort, t for chronological sort)
pwd Display work path
mkdir dir1 Create directory ‘dir1’
mkdir dir1 dir2 Create both directories
mkdir -p /tmp/dir1/dir2 Create a directory tree
mv dir1 dir2 Move/rename a directory
rm -f file1 Delete “file1”
rm -rf dir1 Delete the contents of directory ‘dir1’ and its subdirectories

Viewing file Contents

The command parsing
cat file1 The contents of the file are viewed forward from the first byte
head -2 file1 View the first two lines of a file
more file1 View the contents of a long file
tac file1 View the contents of a file backwards, starting with the last line
tail -3 file1 Look at the last three lines of a file
vi file Open and browse the file

Text content processing

The command parsing
grep str /tmp/test Find ‘STR’ in file ‘/ TMP /test’
grep ^str /tmp/test Look for lines starting with ‘STR’ in the file ‘/ TMP /test’
grep [0-9] /tmp/test Find all lines in the ‘/ TMP /test’ file that contain numbers
grep str -r /tmp/* Look for ‘STR’ in the directory ‘/ TMP’ and its subdirectories
diff file1 file2 Find the differences between the two files
sdiff file1 file2 Shows the differences between two files in a comparative manner
vi file
operation parsing
i Enter the edit text mode
Esc Exit the edit text mode
:w Save current changes
:q Exit the VI without saving the configuration file
:wq Save the configuration and exit the VI

Query operation

The command parsing
find / -name file1 Start with ‘/’ and go to the root file system to find files and directories
find / -user user1 Find files and directories belonging to user ‘user1’
find /home/user1 -name *.bin Look for files ending in ‘.bin ‘in the directory’/home/user1 ‘
find /usr/bin -type f -atime +100 Find executable files that have not been used in the past 100 days
find /usr/bin -type f -mtime -10 Find files that have been created or modified in the last 10 days
locate *.ps Look for files ending in ‘.ps’ and run the ‘updatedb’ command first
The find -name “*. [ch] ‘| xargs grep – E’ expr ‘ Look for ‘expr’ in all.c and.h files in the current directory and its subdirectories
The find -print0 -type f | xargs – r0 grep -f ‘expr’ Look for ‘expr’ in regular files in the current directory and its subdirectories
The find – maxdepth 1 -type f | xargs grep -f ‘expr’ Look for ‘expr’ in the current directory

Compression and decompression

Package compression:

Tar -zcvf newfilenance.tar. gz filename Compress a filename file or directory into newfilenance.tar.gz

Unpack and decompress:

Gz Decompress the filenames. Tar. gz file

The command parsing
bzip2 file1 Compression file1
bunzip2 file1.bz2 Unpack the file1..bz2
gzip file1 Compression file1
gzip -9 file1 Maximize the compression of filE1
gunzip file1.gz Unpack the file1. Gz
tar -cvf archive.tar file1 Tar (-c: create a compressed file; -v: displays all processes. -f: Use the file name, which is required, and is the last parameter)
tar -cvf archive.tar file1 dir1 Package file1, dir1 into archive.tar
tar -tf archive.tar Displays the contents of a package
tar -xvf archive.tar Release a packet
tar -xvf archive.tar -C /tmp Release the package to the/TMP directory
zip file1.zip file1 Create a zip package
zip -r file1.zip file1 dir1 Compress files and directories into a ZIP package
unzip file1.zip Decompress a zip file to the current directory
unzip test.zip -d /tmp/ Decompress a zip package to/TMP

Yum installer

Yum install [package] Manually select install


Yum -y install [package

The command parsing
yum -y install [package] Download and install an RPM package
yum localinstall [package.rpm] Install an RPM package and use your own repository to resolve any dependencies
yum -y update Update all RPM packages installed in the current system
yum update [package] Example Update an RPM package
yum remove [package] Example Delete an RPM package
yum list Lists all packages installed on the current system
yum search [package] Search the RPM repository for packages
yum clean [package] Example Clear software packages in the /var/cache/yum directory
yum clean headers Delete all header files
yum clean all Remove all cached packages and header files

Network related

The command parsing
ifconfig eth0 Displays the configuration of an Ethernet card
Ifconfig eth0 192.168.1.1 netmask 255.255.255.0 Configure an IP address for the NIC
ifdown eth0 The eth0 network device is disabled
ifup eth0 The eth0 network device is enabled
iwconfig eth1 Displays the configuration of a wireless card
iwlist scan Display wireless network
ip addr show The IP address of the network adapter is displayed

System related

The command parsing
su – Switch to root (not su)
shutdown -h now To turn it off
shutdown -r now restart
top List the Linux tasks that use the most CPU resources (type q to exit)
pstree Show the program as a tree
man ping Check the reference manual (for example, the ping command).
passwd Change the password
df -h Displays the disk usage
cal -3 Displays the calendar for the previous, current, and next month
cal 10 1988 Displays the calendar for the specified month and year
Date — date ‘1970-01-01 UTC 1427888888 seconds’ Converts a number of seconds relative to 1970-01-01 00:00 into time

XSheel 5 Related operations

Window Shortcut keys

The command parsing
Ctrl + u Deletes the character before the cursor to the beginning of the line
Ctrl + k Deletes the character before the cursor to the end of the line
Ctrl + c To cancel the current command is equivalent to Ctrl + Break
Ctrl + a Move the cursor to the ahead of line, equivalent to the usual Home button
Ctrl + e The cursor moves to the end of the line
Ctrl + f Move the cursor forward by one character position
Ctrl + b Move the cursor backward by one character
Ctrl + l Clearing the screen is equivalent to running the clear command
Ctrl + r Displays: no prompt, searches for related history commands based on user input (reverse i-search)
Ctrl + w Deletes the beginning of the word from before the cursor position to the current position
Ctrl + t Swap the two characters before the cursor position
Ctrl + y Paste the last deleted word
Ctrl + Alt + d According to the desktop
Alt + b The cursor moves backward to the previous word
Alt + d Deletes from the cursor position to the end of the current word
Alt + F2 run
Alt + F4 Close the current window
Alt + F9 Minimize the current window
Alt + F10 Maximize the current window
Alt + Tab Switching window
Alt + click Move the window (or scroll the mouse wheel in the bottom taskbar)

Operation tips

Middle mouse button: Paste highlighted text. Use the left mouse button to select text. Place the cursor where you want to paste the text. Click the middle mouse button to paste.

Tab: Automatic command line completion. You can use this when using shell prompts. Type the first few characters of a command or file name, and then press [Tab]. It automatically completes the command or displays all commands that match the typed characters.

Click the middle mouse button in the margin of the scroll bar: the screen is rolled to that place.

Press/directly in the desktop or file manager to enter the location and open the file manager.

In vi or Firefox, press/to enter the quick search mode.

Web links and images can be dragged and dropped onto your desktop or directory for immediate download.

You can get the full pathname in the terminal by dragging the file from the file manager directly into the terminal.

From: blog.csdn.net/o0darknessy…