"Brother's Linux Private Cuisine" 7 Chapter Linux file and directory management exercise answers

Source: Internet
Author: User

Self-organized a bit, share to everyone, these exercises are really very classic!

1. What is an absolute path versus a relative path?

The absolute path is relative to the/directory path, such as/home/user;

Relative path is relative to the current working directory, such as your system has a/home/user/test directory, at this time you in the/home/user directory, then./test is the relative path.

2. How do I change the name of a directory? For example,/home/test becomes/home/test2.

Mv/home/test/home/test2

3.PATH What is the meaning of this environment variable?

Here's a look at path:

[Email protected] ~]# echo $PATH/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

When you enter a command, the system will search for this command one by one according to the path set by path, until it is found, and if multiple paths have this command, the first one found in path setting paths is whichever.

What are the uses and advantages of 4.umask?

Use: can be used to set the default permissions for the file or directory when creating a file or directory;

Pros: In some special production environments, if you need to create the default permissions for files or directories, you can change the umask to meet our needs, so that you can control files and directories more rationally.

5. When a user's umask is 033 and 044, what is the file and directory permissions he created?

For umask settings and how to calculate the default permissions for files and directories, refer to my other blog post:

"Talking about the Umask value and its corresponding file permission in Linux"

http://xpleaf.blog.51cto.com/9315560/1679861

Here's a straight answer:


033 044
File permissions -|rw-|r--|r-- -|rw-|-w-|-w-
Directory Permissions -|rwx|r--|r-- -|rwx|-wx|-wx

6. What is SUID?

Suid is a special file permission, when the file has Suid permissions, the other user (not the file owner) if the file has X permission (if the file can also be executed, so suid is generally for the binary command file), when the file is executed, the file owner will be temporarily granted permission. To execute the file again.

7. When I want to query/usr/bin/passwd This file's traditional permissions, file types and file hidden properties, what command can I use to query?

To query Traditional permissions:

[Email protected] ~]# ls-l/usr/bin/passwd-rwsr-xr-x. 1 root root 30768 February 2012/usr/bin/passwd

Query file type:

[[email protected] ~]# file/usr/bin/passwd/usr/bin/passwd:setuid ELF 64-bit LSB Shared Object, x86-64, version 1 (SYSV) , dynamically linked (uses shared libs), for Gnu/linux 2.6.18, stripped

Query Hidden properties:

[Email protected] ~]# lsattr/usr/bin/passwd-------------e-/usr/bin/passwd

8. Try to find out which of the current Linux systems have all the suid files.

[[email protected] ~]# Find/-perm +4000 output omitted

Note the difference between the following three symbols:

4755 The file permissions for the lookup must be:-| rws|r-x|r-x
-4755 The file permissions to find need to be satisfied: The file must have at least the same permissions as 4755 or-|rws|r-x|r-x, or more permissions than
+4755 The file permissions to find need to be met: File permissions can be at most the same as 4755 or-|rws|r-x|r-x, or have fewer permissions

9. Find the file size from 50KB to 60KB under/etc, and list the permissions in full (LS-L).

I'll look for 50KB to 100KB here.

Method One:

[Email protected] ~]# find/etc-size +50k-size-100k-exec ls-l {} \; -rw-r--r--. 1 root root 88371 May 22:24/etc/termcap-rw-r--r--. 1 root root 65536 January 2010/etc/pki/nssdb/cert8.db

Method Two:

[Email protected] ~]# find/etc-size +50k-a-size-100k-exec ls-l {} \;-rw-r--r--. 1 root root 88371 May 22:24/etc/termcap-rw-r--r--. 1 root root 65536 January 2010/etc/pki/nssdb/cert8.db

Method Three:

[Email protected] ~]# find/etc-size +50k-a-size-100k | Xargs Ls-l-rw-r--r--. 1 root root 65536 January 2010/etc/pki/nssdb/cert8.db-rw-r--r--. 1 root root 88371 May 22:24/etc/termcap

In fact, the first method and the second method is exactly the same, parameter-A is the meaning of and, that is, to meet the conditions set by the two parameters at the same time, that is, 50KB to 60KB, in fact, the default is-a parameter. So it is not difficult to understand, if it is-o, that is, or even if meaning, that is, two conditions before and after the-O, either a satisfying or two at the same time can be satisfied. Because the topic is to find documents, so actually add-type F will be better, but understanding is good, I do not add here, the following topic is also.

10. Find/etc below, the file size is greater than 50KB and the file owner is not the root file name, and the file owner is not the root file name, and the permissions are fully listed (LS-L).

Here I find the file owner is not a Oldboy user.

Method One:

[[email protected] ~]# find/etc-size +50k!      -user oldboy-exec ls-l {} \; -rw-r--r--. 1 root root 88371 May 22:24/etc/termcap-rw-------. 1 root root 125811 November 2013/etc/ssh/moduli omitted output

Method Two:

[Email protected] ~]# find/etc-size +50k-not-user oldboy-exec ls-l {} \; -rw-r--r--. 1 root root 88371 May 22:24/etc/termcap-rw-------. 1 root root 125811 November 2013/etc/ssh/moduli omitted output

Look at the topic, "and" is the meaning of and, so add-a parameter can be. As for "!", in fact means "non" meaning, and-not is the same.

11. Find the files below/etc with a capacity greater than 1500KB and a capacity equal to 0.

This is the word "and", according to the meaning of the topic to understand, should be "or" meaning, otherwise there is no more than 1500KB and equal to 0 of the document it? So here you can use the-o parameter.

[Email protected] ~]# find/etc-size +1500k-o-size 0k/etc/environment/etc/selinux/targeted/modules/active/netfilter _contexts/etc/selinux/targeted/modules/active/policy.kern Omit output


OK, that's all, if there is any problem, please tell me, thank you!

This article is from the "fragrant fluttering leaves" blog, please make sure to keep this source http://xpleaf.blog.51cto.com/9315560/1680374

"Brother's Linux Private Cuisine" 7 Chapter Linux file and directory management exercise answers

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.