Linux directories and Permissions

Source: Internet
Author: User
Tags parent directory

1. Rmdir-p is used to delete a list of directories, such as Rmdir-p/TMP/TEST/1/2/3 if/tmp/1/2/below in addition to the 3 directory has a 4 directory, 4 directory also has a 5 directory, then whether it can be successfully deleted? Rmdir-p the error when deleting a nonexistent directory?
Rmdir-p cannot delete a non-empty directory successfully, RMDIR-P will error when deleting a nonexistent directory, prompting "no file or directory"

2. Delete a directory or file, before the deletion will be asked if we delete, if the direct return, whether to delete it? What happens if the input is not ' Y ' and not ' n '?
The direct carriage return will not be deleted if the input is not ' y ' nor ' n ' will not be deleted

3. I want to build a list of directories, such as/HOME/1/2/3/4.
Mkdir-p/HOME/1/2/3/4

4. What happens if the target file is a non-directory and exists file when using the MV command?
Will be prompted if you want to overwrite that file

5. Use less to view the file/etc/passwd search for a total of several ' root ', which key can be moved up/down one line?
A total of 4 ' root ', press N to move down one line, press N to move up.

6. Think about it if we set the permissions for a directory to rwxrw-rw-, can other users be able to access the contents of LS in this directory?
Because the other user's permission to the directory is read and write, there is no execute permission, so the content in LS is not a problem, but cannot enter the directory, because into the directory, is equivalent to "execute" this directory.

7. If you set Umask to 001, what is the user's permission to create directories and files by default?
The formula for calculating default permissions through Umask is:
1) directory (RWXRWXRWX)-(umask) = (directory permission), in this case umask=001= (--------x), so the permissions of the directory is (RWXRWXRWX)-(--------x) = (rwxrwxrw-) =776
2) file (rw-rw-rw-)-(umask) = (file permission), in this case umask=001= (--------x), so the permission of the file is (rw-rw-rw-)-(--------x) = (rw-rw-rw-) =666
So it concludes that when Umask is 001, directory permissions are 776 and file permissions are 666

8. Find out the files that have been changed in the/var/directory in the last day with find? Find out the files changed in the/root/directory within the next hour?
find/var/-type f-mtime-1
find/root/-type f-mmin-60

9. Use Find to find files that have never been changed in the/etc/directory for a year?
find/etc/-type F! -mtime-365

10. Why is a hard link not linked to a directory? are hard-linked files space-intensive, and can hard-link files be created in a collapsed partition?
Because there will be one in each directory. and. In other words, each directory below the subdirectory will certainly have itself and its first level of directory, then once the hard link is set to create a confusion, the settings will lead to a dead loop. A hard-linked file does not take up space, it only copies the inode information for the file, and hard-linked files cannot be created across partitions.

What are the symbols for the Linux system: Plain text files, binary files, directories, linked files, block devices, socket files, and serial port devices?
Ordinary files and binaries with-indicates, the directory with D, the link file (should be said to be soft connection) with L, block equipment with B, the socket is expressed in S, the serial port device is denoted by C.

12. How to change the Dira directory and all files and directories under the directory to the owner of the User1, the group is the users?
Chown-r user1:users Dira

Linux system, default directory permissions why? What are the permissions for a document? expressed in three digits. We can change the default permission values for directories and documents by modifying the value of umask, how do we pass the Umask value to the default permissions?
Default directory permissions are 755, document permissions are 644, directory default permissions = (rwxrwxrwx)-(umask), file default permissions = (rw-rw-rw-)-(umask)

14. Modify the permissions of the DIRB directory, so that the owner of the main readable writable executable, the group can be read executable, other users are unreadable and non-writable, and what commands to use?
chmod DIRB

15. How can I make a file write-only and cannot be deleted? How can I make a file unable to be deleted, renamed, linked, written, or added to the data?
Chattr +a file so that files can only be written and cannot be deleted
Chattr +i file makes it impossible to delete, rename, link, write, add data

What does the next dot '. ' and two dots ' ... ' represent?
A point represents the current directory, and two points represent the parent directory.

. CD-What does that mean?
CD-Represents the last directory you have entered

18. When using LS to view a directory or a file, what does the value of the second column mean? If the value of this column in a directory is 3, how is this 3 obtained?
The second column value indicates that there are several files using the same inode, if a directory of this column is 3, we can get it by using Ls-al dir/|grep ' ^d ' |wc-l this command

19. If there is no locate command, which package do we need to install? The initial use of the Locate command will error "Can not open '/var/lib/mlocate/mlocate.db ': No such file or directory", what do we need to do?
No locate command, need to install Mlocate package, yum install-y mlocate, first use error, is because the corresponding database file has not been generated, the command is generated manually: UpdateDB

20. When copying a file, if the target file exists will ask us whether or not to overwrite, how do we stop asking?
Copy using/BIN/CP:/BIN/CP a.txt b.txt

21. How to dynamically display the contents of a file, if the content of this file has been increased.
Tail-f file

22. What is the command to change the file read and write execution permissions? How do I change the permissions of all files (without directories) in one directory to 644?
chmod used to change file permissions, find./-type F |xargs chmod 644

23. How do I see what the current user's home directory is?
Echo $HOME

24. If a directory is available for anyone to write, how can the files in that directory only allow the owner of the file to change?
chmod o+wt dir

25. Describe the difference between soft links and hard links?
A soft connection can be understood as a shortcut to a source file, a soft connection file that records the path of the source file, and takes up very little space. When the source file is deleted, then the soft connection file becomes a bad file and cannot be used.
Hard link and source file inode information is exactly the same, you can say that the hard-link file just copied a copy of the source file inode information, in our opinion, hard-link files and source files No difference, delete any one file is not affected by the other, the only one is missing an inode, Hard links can only be created under the same partition, and soft connections are unrestricted. Hard-link files and source files may look like two files, but only occupy one file of disk space.

What time does the cat a.txt change a.txt? chmod 644 A.txt will change the time of a.txt? What about VIM? What about direct touch?
Cat modifies Atime, chmod changes CTime, vim changes atime,ctime,mtime, and touch changes three times.

Extension section:
1. Simply describe what the inode is and not more than 100 words.
The inode is a container for documenting the properties of a file in a Linux system, which records information such as the file name, the size of the file, the owner group, the permissions of the file, the access time of the file, the modification/creation time, and the change time (change inode information), and so on. In a Linux system, each file will have a unique inode.

2. Describe the role of suid Sgid.
SUID: Used for binary executables, which allows the user to temporarily own the owner of the file when the file is executed, a typical file is/USR/BIN/PASSWD, it changes the user's password when these files are changed:/ETC/PASSWD and/etc/shadow, these files default to normal users without write permission.
Sgid: For a directory, the files created by the user in the directory have the same genus as the directory.

3. How do Atime, CTime, mtime in Linux differentiate?
Atime the last access time for the file;
CTime changes the time when the Inode information is last changed, such as changing the filename, file permissions, writing new content (changing the file size), and so on.
Mtime the last time the file content was changed;

4. Briefly describe what is SELinux?
SELinux is a security mechanism specific to the Redhat/centos system that provides mandatory access control that restricts the process from accessing only those files that are needed in its tasks. SELinux is a mandatory access control (MAC) system available in the 2.6 version of the Linux kernel. For the currently available Linux security modules, SELinux is the most versatile and well-tested. SELinux incorporates multi-level security or an optional multi-class policy in the type enforcement server and employs a role-based access control concept.

5. Find the current directory settings set_uid files, in order to make the problem easier, set the file permissions to find 4644, please refer to the above 9.
Find. -perm 4644

Linux directories and Permissions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.