Linxu's help instructions

Posted by WBSKI on Tue, 28 Dec 2021 21:58:41 +0100

Linxu's instructions

Usage scenario

When you are not familiar with an instruction

Get help

Basic grammar

man [command or configuration file]

NAME
       ls - list directory contents

SYNOPSIS
       ls [OPTION]... [FILE]...

DESCRIPTION
       List   information  about  the  FILEs  (the  current  directory  by
       default).  Sort entries alphabetically if  none  of  -cftuvSUX  nor
       --sort.

       Mandatory arguments to long options are mandatory for short options
       too.

       -a, --all
              do not ignore entries starting with .

       -A, --almost-all
              do not list implied . and ..

       --author
              with -l, print the author of each file

       -b, --escape
              print octal escapes for nongraphic characters

help instruction

help instruction

View help information of cd command

[root@localhost ~]# help cd
cd: cd [-L|-P] [dir]
    Change the shell working directory.
    
    Change the current directory to DIR.  The default DIR is the value of the
    HOME shell variable.
    
    The variable CDPATH defines the search path for the directory containing
    DIR.  Alternative directory names in CDPATH are separated by a colon (:).
    A null directory name is the same as the current directory.  If DIR begins
    with a slash (/), then CDPATH is not used.
    
    If the directory is not found, and the shell option `cdable_vars' is set,
    the word is assumed to be  a variable name.  If that variable has a value,
    its value is used for DIR.
    
    Options:
        -L	force symbolic links to be followed
        -P	use the physical directory structure without following symbolic
    	links
    
    The default is to follow symbolic links, as if `-L' were specified.
    
    Exit Status:
    Returns 0 if the directory is changed; non-zero otherwise.
[root@localhost ~]# 

File directory class Command

pwd instruction

Displays the absolute directory of the current working directory

[root@localhost ~]# pwd
/root
[root@localhost ~]# 

ls instruction

Displays all files and directories in the current directory, and the registration is hidden

ls -a displays all information

ls -l: displayed in list form

[root@localhost ~]# ls -l
total 64
-rw-------. 1 root root  3350 Aug  9 05:52 anaconda-ks.cfg
-rw-r--r--. 1 root root 41918 Aug  9 05:52 install.log
-rw-r--r--. 1 root root  9154 Aug  9 05:50 install.log.syslog

cd instruction

Instructions for switching directories

parameter

cd ~: return home directory

cd... Return to the previous directory

Relative path and absolute path

Absolute path: locate from the root directory

Relative road strength: locate the required directory from the current working directory

mkdir instruction

Create directory

Common options: mkdir -p: create multi-level directory

[root@localhost home]# mkdir -p /dog/1/
[root@localhost home]# cd dog
[root@localhost dog]# ls
[root@localhost dog]# ll
total 0
[root@localhost dog]# cd /1/
-bash: cd: /1/: No such file or directory
[root@localhost dog]# cd ..
[root@localhost home]# ls
a  dog  test  tiger  xiaoming  zwj
[root@localhost home]# mkdir -p /home/animal/tiger/
[root@localhost home]# ls
a  animal  dog  test  tiger  xiaoming  zwj
[root@localhost home]# cd /animal
-bash: cd: /animal: No such file or directory
[root@localhost home]# cd /animal/
-bash: cd: /animal/: No such file or directory
[root@localhost home]# pwd
/home
[root@localhost home]# cd animal/
[root@localhost animal]# cd tiger/
[root@localhost tiger]# 

Delete directory

rmdir: delete directory

be careful:

If the directory is not empty, it cannot be deleted. If it is not empty, it needs to be deleted. If it is not empty, it needs to be instructed to rm -rf delete

touch command

Create an empty file

touch file name

cp instruction

cp [options] source dest

Common options- r: Copy entire folder recursively

[root@localhost home]# touch aa.txt
[root@localhost home]# mkdir bbb
[root@localhost home]# cp aa.txt bbb/
[root@localhost home]# cd bbb/
[root@localhost bbb]# ls
aa.txt
[root@localhost bbb]# 

rm instruction

Remove file or directory

attribute

rm -rf: delete entire directory

rm -f: force deletion without reminder

mv instruction

Move or rename files

cat instruction

View file content cannot be modified

[root@localhost home]# cat aaa.txt
sdhakjshdkj

[root@localhost home]# 

>Instructions and > > instructions

This file will be overwritten, and > > the contents of the file will continue to be appended

echo command

Output content to console

Common:

1. Output environment variables

[root@localhost home]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

2. Output simple text content

head instruction

Display the contents at the beginning of the file. The first 10 lines are displayed by default

head -n rows

Real time monitoring of text content changes

tail -f file name

In instruction

Soft connect instruction

Syntax: ln -s original file / directory connection name

Delete soft connection:

[root@localhost home]# clear
[root@localhost home]# ls
a  aaa.txt  test  test2  tiger  xiaoming  zwj
[root@localhost home]# Yes
-bash: Yes: command not found
[root@localhost home]# 
[root@localhost home]# ln -s aaa.txt b
[root@localhost home]# ls
a  aaa.txt  b  test  test2  tiger  xiaoming  zwj
[root@localhost home]# head b
total 24
drwx------. 26 a    a      4096 Aug  9 18:57 a
-rw-r--r--.  1 root root      0 Aug  9 19:11 aaa.txt
drwxr-xr-x.  3 root root   4096 Aug  9 19:05 test
drwx------.  4 test test   4096 Aug  9 18:54 test2
drwxr-xr-x.  2 root root   4096 Aug  9 07:53 tiger
drwx------.  4  501    501 4096 Aug  9 08:14 xiaoming
drwx------.  4 zwj  wudang 4096 Aug  9 08:42 zwj
total 28
drwx------. 26 a    a      4096 Aug  9 18:57 a
[root@localhost home]# rm -rf b
[root@localhost home]# ls
a  aaa.txt  test  test2  tiger  xiaoming  zwj
[root@localhost home]# 

Histoy instruction

View instructions that have been executed

find instruction

find search scope options

grep directive and pipe symbol "I"

grep: filter and find. The pipeline symbol indicates that the processing result output of a command is passed to the subsequent instruction execution

Compression and decompression

gzip/gunzip

gzip: compressed file

gunzip: unzip

The original file will not be retained

zip/unzip: used for project upload

tar command

tar packing instruction

Topics: Linux