In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The above is the introduction of file management commands in Linux, the content is more comprehensive, Xiaobian believes that some knowledge points may be what we may see or use in our daily work. I hope you can learn more from this article.
1.
Linux distributions follow the LSB(Linux Stadards Base) rule, use consistent, relevant base directory names, use the root filesystem, and use the FHS(Files Hierarchy Standard) hierarchy.
The purpose of each directory under the root directory
/boot: directory where boot files are stored, kernel files (vmlinuz), boot loader (bootloader, grub) are stored in this directory
/bin: Basic commands used by all users; cannot be associated with independent partitions, programs that will be used immediately after OS startup
/sbin: Basic command for administrative classes; cannot be associated with a separate partition, and the program will be used when the OS starts
/lib: Basic shared library files and kernel module files that the program depends on at startup (/lib/modules)
/lib64: Auxiliary shared library file storage location dedicated to x86_64 systems
/etc: Configuration file directory
/home/USERNAME: home directory of ordinary users
/root: Administrator's home directory
/media: Portable mobile device mount point
/mnt: temporary file system mount point
/dev: storage location for device files and special files
b: block device, random access
c: character device, linear access
/opt: Installation location of third-party applications
/srv: Data used by services running on the system
/tmp: temporary file storage location
/proc: Used to export kernel and process information related virtual file system
/sys: Virtual file system for outputting information about hardware devices on the current system
/selinux: security enhanced Linux, storage location of selinux related security policies and other information
2.
The metadata of the file includes the attribute size of the file, the creation time, three time stamp information, and the main group.
Use ls -al to view. Most metadata, 3 timestamps View using stat + filename
Timestamp information is divided into
three time stamps
acess time access time, atime, time to read and write file content
modify time, mtime, the time at which the contents of a file are changed
change time, ctime, the time at which metadata of a file changes
To modify it, use the touch command.
touch [option]... Files
-c Not created if specified file path does not exist
-a modifies access time only
-m modify time only
3.
Hard links do not create inode, even though all inode used are the same. Soft links create new inode. Hardlink access attributes are identical to the source file, with no l identifier. The access attribute of the soft link indicates l, and the access permission cannot be set, it can only be 777, the real permission depends on the source file. If you move the source file, soft links are not found, while hard links do not have this problem because soft links store the location of the file.
Hard link is a kind of reference relationship, a source file to establish a hard link, reference count plus 1, delete a file (hard link file or source file), reference count minus 1, when the reference count is 0, the file is really deleted. Deleting the source file soft link simply doesn't find the target file.
Hard links to directories cannot be created, hard links between files on different file systems cannot be created, and soft links do not have these restrictions.
4. File management commands on Linux
directory management command
ls: List the contents of the specified directory Format:
ls [OPTION]... [FILE]...
-a: Show all files including hidden files
-A: Display except... And... all file
-l, --long: Displays detailed attribute information of the file
-h: Unit conversion for file size, which may affect accuracy
-d: View the directory itself rather than the files inside it.
-r: Display files in reverse order
-R: Recursive display file
Example: ls -lah / --Show all files (including hidden files) under/directory in detail
ls -ldh /etc --Detail the/etc directory itself
ls -lhv / --Show all files in/directory in reverse order (including hidden files)
ls -R /etc --Recursively display all files under/etc
mkdir: Create directory format:
mkdir [OPTION]... DIRECTORY...
-p: Automatically create parent directories on demand
-m: Given permissions when creating directories
Example: mkdir -p /data/test/A/B --recursively create three directories/test/A/B under/data directory
mkdir -m 711 -p /data/MODE/A --Recursively create MODE/A two directories under/data directory and specify permissions of directory A as 711
rmdir: delete directory format:
rmdir [OPTION]... DIRECTORY...
-p: Delete a directory if its parent directory is empty
Example: rmdir -p /data/test/A --After deleting A directory, test directory is empty, delete it together
cd: switch directories
Example: cd..: Switch to parent directory
cd ~: switch back to your home directory
cd -: switch back and forth between previous directory and current directory directly
pwd: Display current directory
(2) Document Management Command--
cp: copy
Format: Single Source Copy: cp [OPTION]... [-T]SOURCE DEST (create if DEST does not exist, overwrite if it exists)
Multi-source replication: cp [OPTION]... SOURCE... DIRECTORY (DEST must be directory)
-i: Interactive copy, i.e. remind user to confirm before overwriting
-f: Force overwrite target file
-r,-R: Recursively copy directories
Example: cp -if /data/[1-3].txt /data/test --test must be a directory, copy the three files together into test
cp -r /data /practice --copy the data directory and its contents into practice
mv: shear
Format: Single Source Copy: mv [OPTION]... [-T]SOURCE DEST (create if DEST does not exist, overwrite if it exists)
Multi-source replication: mv [OPTION]... SOURCE... DIRECTORY (DEST must be directory)
-i: Interactive copy, i.e. remind user to confirm before overwriting
-f: Force overwrite target file
Example: mv -i /data/[1-3].txt /practice --Cut three txt files from/data directory to/practice
rm: deleted
Format: rm [OPTION]... FILE...
-i: Interactive copy, i.e. remind user to confirm before overwriting
-f: Force overwrite target file
-r, -R: Recursive processing, delete all files under the specified directory, including the directory
Example: rm -rf /practice --recursively delete/practice directory
(3) Text Content Management Command
cat: forward view text content
Format: cat [OPTION]... [FILE]...
-n: Number the lines of text displayed
-E: Display end-of-line symbol $
Example: cat -n /etc/fstab --View/etc/fatab contents and display line numbers
tac: flashback view text content
Format: tac [OPTION]... [FILE]...
Example: tac /etc/passwd --flashback view text content
head: Display text content, default to display the first 10 lines
Format: head [OPTION]... [FILE]...
-n #: Display text header #line content
Example: head -5 /etc/passwd --Display the first 5 lines of the/etc/passwd file
tail: display text content, default to display the last 10 lines
Format: tail [OPTION]... [FILE]...
-n #: display #line content after text
-f: Do not exit after viewing the content at the end of the file, follow the display of new lines
Example: tail -8 /etc/passwd --Display the last 8 lines of the/etc/passwd file
more: Display text content on separate screens, stop displaying one screen at a time
Format: more [options] file [...]
Space key: display text next screen content
Enter: Display only one line below text
b key: display one screen of text
q key: exit
less: display text content on separate screens, do not actively quit
Format: less [options] file [...]
Space key: display text next screen content
Enter: Display only one line below text
b key: display one screen of text
q key: exit
cp -r /etc/profile /tmp/
Use vim editing in admin to try to enter
%s#^[[:space:]]([^[:space:]])#\1#g1
About linux file management command to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you like this post, share it with more people.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.