Linux command note su sudo df du

Source: Internet
Author: User

#id/whoami View Current user

SU Switch User

#su-username

"-" function, plus after initializing the various environment variables of the current user

Switch environment variables. No-change the past, the directory will not change, the path will not change

Comparisons are as follows:

Su aming123

[Email protected] root]$ pwd

/root

[Email protected] root]$ echo $PATH

/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

[[email protected] root]$ ls

LS: Unable to open Directory.: Insufficient permissions

[[Email protected] root]$ exit

Exit

[Email protected] ~]# su-aming123

[Email protected] ~]$ pwd

/home/aming123

[Email protected] ~]$ echo $PATH

/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/aming123/bin

[Email protected] ~]$

Normal user under #su direct switch to root when environment variable or current user's environment variable

Normal user under #su-switch to root, environment variable also switch to root environment variable

Command: #su-C "command" username can execute "command" without switching to username under Uaername user identity

Such as:

[[Email protected] ~] #su-C "mkdir/tmp/1212" aming123

[[email protected] ~]# Su-C "ls-ld/tmp/1212" aming123

Drwxrwxr-x 2 aming123 aming123 4096 December 01:59/tmp/1212

Similarities and differences of #logout与 #exit

Exit exits the console, for multi-layered shells, for layer-by-step exit, to the top-level shell, if you execute command bash in the shell, enter the child shell, we can use Exit to exit the current child shell, but not use logout to exit the child shell. When it comes to the most primitive shell, we use exit or logout to exit. If the user has not been switched, both commands exit the console. If you switch users, both commands log off the current user and return to the previous user.


sudo common use temporary as root to execute commands

#visudo to open sudo configuration file

Found: Root all= (All) is added after

aming123 all= (Root)/bin/ls lets the aming123 ordinary user get root permission to execute the LS command, but LS must be written as an absolute path.

Use # to annotate a row

#sudo-L to see if the current user has the sudo command to execute.

If you add multiple commands separated by commas

aming123 all= (Root)/bin/ls,/usr/bin/passwd

If you let the aming123 user execute the sudo ls/root command, you do not need to enter the password for the aming123 user to set the order:

aming123 all= (Root) nopasswd:/bin/ls

If multiple users are required to execute a command, add multiple to the wheel group, and then limit the wheel group.

%wheel all= (All) all


DF View Partition and Usage

Free to view with swap

DF Default file is in K

Df-k-M (in M)-I (Inode)-H (auto-match unit)-a displays all partitions (including hidden partitions)


Du view file or directory size

Du default is in K units

#du-M-h-b (bytes units)

#du-sh dir/filename View the specified directory dir or file filename size

#du-sh filename/dir View files or directories taking up disk size

#ls-lh Filename/dir View the size of the file or directory itself

Of course #du-sb #ls-lb look at the file size


Linux command note su sudo df du

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.