The second week of linux foundation

Keywords: Operation & Maintenance Anaconda Linux Attribute shell

linux distribution system directory naming rules

Use root file system structure and FHS hierarchy. linux system is strictly case sensitive, and the system directory inherits this feature.

"/: root directory, the highest level directory of all directories

/ bin: the basic command storage directory available to all users

/ sbin: only the command storage directory available to root

Home: home directory of ordinary users

root: super user directory

/ etc: directory where configuration files are stored

/ usr: directory for storing global shared data

Partial third-party application installation directory

"/ dev": the directory where the device files are stored

Null: empty device, device file where all stored data will be discarded

Zero device, output the device file with the specified length of binary 0

/ lib: directory where library files and kernel modules are stored

/ lib64: directory for storing special 64 bit library files

"/ var": directory for frequently changed files and a few configuration files

/ var/log: directory where system logs are stored

/ boot: the directory where the boot files, kernel files and other files used in the system startup process are stored

/ proc: virtual file system for storing kernel and process related files

/ proc/cpuinfo: a file for storing cpu Information

/ medir: the default mount point for removable storage devices

/ mnt: temporary mount point, restart failure

/ tmp: the directory where temporary directories and files are stored. Restart and clear

/ opt: the default installation directory for some third-party applications

 

The metadata information of the file contains

File file name
Size file size
Number of disk Blocks occupied by Blocks
IO block IO block size
Type of regular file
Device
Inode inode node number
Number of Links linked
Access to access files
Uid owner id and owner
Gid group id and group
Last time Access file was accessed
Time when the data content of Modify file is modified
Time when the status of the Chang file changes

You can view the metadata of a file through the stat command, for example:

[root@zfc ~]# stat anaconda-ks.cfg
  File: 'anaconda-ks.cfg'
  Size: 1968      	Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d	Inode: 4297153635  Links: 1
Access: (0600/-rw-------)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2019-11-06 18:22:12.433397525 +0800
Modify: 2019-11-06 18:22:12.433397525 +0800
Change: 2019-11-06 18:22:12.822401901 +0800
 Birth: -

You can modify the time stamp of a file through the touch command, for example:

[root@zfc ~]# touch anaconda-ks.cfg 
[root@zfc ~]# stat anaconda-ks.cfg 
  File: 'anaconda-ks.cfg'
  Size: 1968      	Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d	Inode: 4297153635  Links: 1
Access: (0600/-rw-------)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2019-11-09 18:24:00.413843056 +0800
Modify: 2019-11-09 18:24:00.413843056 +0800
Change: 2019-11-09 18:24:00.413843056 +0800
 Birth: -

 

link

Soft link includes soft link and hard link. Soft link is a file created to point to a new inode of data block. Different from the source file inode, deleting the soft link of the source file is invalid. Hard link is to create a new data block to store the same content, but the same inode, delete the source file hard link is still valid.

[root@zfc ~]# touch ln          #Create a source file
[root@zfc ~]# ln -s ln ln_s     #Create soft link
[root@zfc ~]# ln  ln ln_h       #Create a hard link
[root@zfc ~]# stat ln |grep -i inode     #View source file inode
Device: fd00h/64768d	Inode: 4297103463  Links: 2
[root@zfc ~]# stat ln_h |grep -i inode   #View hard link inode
Device: fd00h/64768d	Inode: 4297103463  Links: 2
[root@zfc ~]# stat ln_s |grep -i inode   #View soft link inode
Device: fd00h/64768d	Inode: 4297153591  Links: 1
[root@zfc ~]# rm -f ln          #Delete source file
[root@zfc ~]# ll ln*
-rw-r--r-- 1 root root 18 Nov  9 18:31 ln_h         #Can be opened normally
lrwxrwxrwx 1 root root  2 Nov  9 18:30 ln_s -> ln   #Link failure, unable to open

 

File management commands

ls: view files in the directory

Show a ll files including hidden files
- A: display all files except. And
- long: display the detailed attribute information of the file
- h: humanized display of file size
- d: view the directory itself rather than its internal files
- r: display files in reverse order
- R: recursive display file

touch: create a file, refresh the time stamp if the file already exists

mkdir: create directory

- p: automatically create the parent directory on demand
- m: given permission when creating directory

cp: copy

- f: force the target file to be overwritten
- R: recursive replication directory

mv: cut the file to the specified directory. If it is cut to the same directory, it will be renamed

- f: force the target file to be overwritten

rm: delete a file or directory

- f: force the target file to be overwritten
- R: recursive processing. Delete all files under the specified directory, including the directory

 

Copy the / etc/profile to the / tmp directory, and use the find and replace command to remove the blank characters at the beginning of the line in the file

[root@zfc ~]# cp /etc/profile /tmp
[root@zfc ~]# sed -i 's/^[[:space:]]*//g' /tmp/profile
[root@zfc ~]# cat /tmp/profile 
# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.

pathmunge () {
case ":${PATH}:" in
case ":${PATH}:" in
*:"$1":*)
*:"$1":*)
;;
;;
*)
*)
if [ "$2" = "after" ] ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
PATH=$PATH:$1
else
else
PATH=$1:$PATH
PATH=$1:$PATH
fi
fi
esac
esac
}

 

Set tab indent to 4 characters in vim

:set tabstop=4

Posted by djremiasz on Sat, 09 Nov 2019 03:50:21 -0800