Summary of some commands in linux environment

1. cd: enter the directory

$ cd ..

Return to the previous directory

cd ./a

Enter the a folder under the current directory.
/ Indicates the current directory

$ cd ./a/4\ 1512\ b

\ Indicates that the following space is part of the file name, so here is the file named "4 1512 b" after entering the file a in the current directory

2. View file space

du -sh *

View all files and occupied space in the current directory

Insert picture description here

df -h

View system space
Insert picture description here

free -h

View the current system memory status
Insert picture description here

3. Linux file compression and decompression

tar is the linux environment decompression command
-c: create compressed file
-x: decompress
-t: view content
-r: append file to the end of the compressed archive file
-u: update the file in the original compressed package
-z: whether it also has the gzip attribute ? That is, do you need to use gzip compression?
-j: Does it also have bzip2 attributes? That is, do you need to use bzip2 compression?
-v: Display files during compression! This is commonly used, but it is not recommended for background execution!
-f: Use the file name, please note that you must pick up the file name immediately after f! Do not add parameters

tar -xjvf p7zip_16.02_src_all.tar.bz2

Unzip the file named 'p7zip_16.02_src_all.tar.bz2' in the current directory. The
above parameter description:
x: unzip
j: bz2
f: specify the file

Usually after decompressing the file, we need to enter the file first, and then install it in the file, so we will have the following command

cd p7zip_16.02

Enter the file

sudo sh install.sh

Install the executable program in the file, as shown in the figure below indicates successful installation
Insert picture description here

4. Create a folder

mkdir pyCharm

Create a new folder named 'pyCharm' in the current directory

5. Display the content list and permissions in the current directory in long format

ls -l

The output information from left to right includes the file name, file type, permission mode, number of hard links, owner, group, file size, and file last modification time.
ex1:

-rw-rw-r--   1  using using  3102  7月 22 17:06  test.c 
drwxrwxr-x  2  using using  4096  7月 22 18:39  testdir
lrwxrwxrwx  1  using using  17   7月 22 18:43  shared -> /media/sf_shared/

Where 'testdir' is the directory file and 'shared' is the soft link file

The first field: the first letter represents the file type, where "-" is a normal file, "d" is a directory file, "c" is a character device file, "b" is a block device file, and "p" is a pipe file. "l" is a link file and "s" is a socket file. "Rwx" means having read, write, and execute permissions, and "-" means no corresponding permissions. The three "rwx" represent the file owner, the user group where the file owner belongs, and other users' permissions on the file in turn.

The second field: the number of file hard links

Third field: file owner

Fourth field: the group of the file owner

Fifth field: file size (in bytes)

The sixth field: the last change time of the file

Seventh field: file name (if it is a linked file, the path of the original file linked to it is additionally displayed)
 
 ex2:Insert picture description here

6. Which command

which python

which command is used to find files (usually executable files)
which command can find files that meet the conditions in the directory set by the environment variable $ PATH
Insert picture description here

7. whereis command

whereis python

Used to find all files related to python, including original code, binary files or help files
Insert picture description here

8. Other common Linux commands

ls: list directories
cd: switch directories
pwd: display the current directory
mkdir: create a new directory
rmdir: delete an empty directory
cp: copy files or directories
rm: remove files or directories
mv: move files and directories, or Modify the names of files and directories

Other reference materials:
https://www.runoob.com/linux/linux-file-content-manage.html

Published 69 original articles · praised 11 · 20,000+ views

Guess you like

Origin blog.csdn.net/weixin_41636030/article/details/104146563