Common Ubuntu Linux Commands

1 Compress and Extract Files

7zip is recommended for compressing and extracting files because it supports archives larger than 2 GB and its commands are relatively simple.
1) Install 7zip

sudo apt-get install p7zip-full p7zip-rar

2) Extract files

7z x yourfile.zip

The command above extracts the files into a folder with the same name as the archive. To extract them into the current folder, use 7z e.
3) Compress files

7z a -t7z files.7z *.txt

4) Other compression and extraction commands for reference:
Command to extract a tar.gz archive:

tar -zxvf ×××.tar.gz

Command to extract a tar.bz2 archive:

tar -jxvf ×××.tar.bz2

2 Check Disk Usage

1) Check the percentage of space used on each partition

df -h

2) Check the size of each immediate subdirectory in the current directory

du -h --max-depth=1

3 View the First or Last n Lines of a File

To view the first 10 lines of test.log, use this command:

head -n 10 test.log

To view the last 10 lines of test.log, use this command:

tail -n 10 test.loge

4 Take a Screenshot After a Delay

If a keyboard shortcut makes it difficult to capture a right-click menu or something similar, use this command to take a screenshot after a delay:

gnome-screenshot --delay 10

The command automatically captures the entire screen 10 seconds after you run it. Use that time to open the menu you want to capture, then wait for the screenshot.

5 Symbolic Links

Use the following command to create a symbolic link:

ln -s 源文件 目标文件

Add a Comment

Your email address will not be published. Required fields are marked *