Chapter 5 Linux Utility Tools
5.2 Basic Utilities
ls: List all files or folder names under the current foldercat: Display the contents of the target text file
rm: Delete the target file
less or more: Display the text file in split screen (when the file content exceeds one page)
hostname: Display the system name
5.3 File operations
cp: Copy the source file to the target pathmv: Change the file name
lpr: Print the file
grep: Find a string (search one or more files for a given string, and the results display the file lines containing the search string , does not modify the search file)
head: Display the file header (the first 10 lines of information of the file are displayed by default, the number of lines can be specified)
tail: Display the end of the file
sort: Display the file content in order (sort the file content by line)
uniq: Delete duplicate lines in a file
diff: compare two files (show all the differences between the two, but does not change the content of any file)
file: display file attribute information
5.4 Pipe (|): realizes communication between processes
Redirect the standard output of one process to the standard input of another processcat months | head # Use the result of cat months as the input of head
5.5 4 Useful Utilities
echo: display textdate: display date and time
script: record shell session
unix2dos: convert Linux file to Macintosh format or Windows format
5.6 Compressing and archiving files
bzip2: compressed files (bzip2 -v filename, suffix is bz2)bunzip2: decompress files compressed by bzip2
bzcat: display files compressed by bzip2
gzip, gunzip and zcat: compressed files (suffix is .gz)
compress: less efficient Compression tool, with .Z extension
: tar: packs and unpacks archive files, packages multiple files into one file, with the suffix .tar. -cvf is for packaging, -tvf is for decompression, and -x can move the archive file to a new directory and then unpack it.
5.7 Positioning command
which: the path of the locating tool, find the first matchingwhereis: the path of the locating tool, find all matching
apropos: search for commands that approximate matching keywords
whatis: search for commands that exactly match
locate: search for files on the local system
5.8 Obtain user information and system information
who: List users on the systemw: List users on the system
5.11 Create and edit files using vim
vim: Create or edit files (after entering the interface, enter i or a to enter input mode, after inputting, press ESC, then :w or ZZ to save the file to disk, press :q to exit)Chapter 6 Linux File System
6.3 Pathname
Absolute path (~/ in the path represents the home directory)Relative path
6.4 Directory commands
mkdir: Create directorycd: Change working directory
Important standard directories and files:
/: Root directory
/bin: Binary files for basic commands - contains the files needed to boot the system and run it for the first time in recovery mode
/boot: Boot loader Static files – Contains all files that boot the system
/dev: Device files – Contains all files representing peripheral devices
/etc: Local computer system configuration files – Contains administrative files, configuration files, and other system files
/etc/passwd: Contains List of all authorized users using the system
/etc/opt: Configuration files for additional software packages placed in the /opt directory
/etc/X11: Local computer configuration for the X Window System
/home: User home directory
/lib: Shared library
/lib/modules: loadable kernel modules
/mnt: mount point for temporarily mounting the file system
/opt: additional software package
/proc: virtual file system used to display kernel and process information
/root: root user’s home directory
/ sbin: basic binary system files - tools for system management stored in /sbin or /usr/sbin /
sys: device pseudo file system
/tmp: temporary files
/usr: second main file level
/usr/bin : Most user commands - Contains standard Linux tool programs
/usr/games: Games and educational software
/usr/include: Header files included in c programs
/usr/lib: Library files
/usr/local: Local file hierarchy results - Contains files and directories that are important to the local area (added by users, not native to the system)
/usr/man: online manuals
/usr/sbin: non-critical binary files for system management
/usr/share: architecture-independent data
/ usr/share/doc: various documents
/usr/share: the main directory of the GNU info system
/usr/src: source code files
/var: variable data - subdirectories contain files whose contents change when the system is running. These files usually Are temporary files, system log files, spool files and user mailbox files
/var/log: Log files
6.5 Directory operations
rmdir: delete directorymv: move files, directory
cp: copy files
6.6 Access rights
Ubuntu Linux supports two methods for controlling who can access a file and how to access it: traditional Linux access permissions and access control lists (ACLs). ACL provides fine-grained access control.There are three types of users who access files: the file owner (owner), a member of the file owner's group (group), and other users (other). Users can try to access ordinary files in three ways: read, write and execute.
ls -l: Display access permissions (file type + file access permissions + ACL flag + number of links + owner + group user + size + modification time + file name)
chmod: change access permissions (the file owner can execute, chmod a+ rw filename, parameters: a represents all users, o represents other users, g represents group users, u represents the file owner)
setuid: When executing a file with setuid (set user ID, set user ID) permission, the file is executed The process will have the privileges of the file owner.
setgid: The setgid (set group id, set group ID) permission means that the process executing the file has the privileges of the group to which the file belongs.
Directory access rights: The difference between a directory and a file is that the directory cannot be executed. However, the execution permission on the directory is defined as: you can use cd to go to the directory, and you can also view the files with read permission in the directory.