Data Warehousing 003 - Review Linux shell command - sudo user user group permissions du-sh find 

First, the user of the user group

[root@localhost ~]#  ll /usr/sbin/user*
-rwxr-x--- 1 root root 74544 2009-11-27 /usr/sbin/useradd
-rwxr-x--- 1 root root 53676 2009-11-27 /usr/sbin/userdel
-rws--x--x 1 root root 32780 2008-09-09 /usr/sbin/userhelper
-rwsr-xr-x 1 root root  6728 2009-06-09 /usr/sbin/userisdnctl
-rwxr-x--- 1 root root 74480 2009-11-27 /usr/sbin/usermod
-rwsr-xr-x 1 root root  6820 2009-07-13 /usr/sbin/usernetctl
[root@localhost ~]# ll /usr/sbin/group*
-rwxr-x--- 1 root root 39120 2009-11-27 /usr/sbin/groupadd
-rwxr-x--- 1 root root 30568 2009-11-27 /usr/sbin/groupdel
-rwxr-x--- 1 root root 30256 2009-11-27 /usr/sbin/groupmod
[root@localhost ~]# 

 

 1, adding users

[root@localhost ~]# useradd xiaodi
[root@localhost ~]# id xiaodi
uid=609(xiaodi) gid=611(xiaodi) groups=611(xiaodi) context=root:system_r:unconfined_t:SystemLow-SystemHigh
[root@localhost ~]# 

  Create a regular user xiaodi, create the default user group xiaodi name, and set the main user group xiaodi, and create / home / xiaodi

  

 

 2, delete users

[root@localhost home]# userdel xiaodi
[root@localhost home]# id xiaodi
id: xiaodi:无此用户
[root@localhost home]# cat /etc/passwd | grep xiaodi
[root@localhost home]# cat /etc/group | grep xiaodi
[root@localhost home]#  

  The group only because xiaodi xiaodi user, when the user deletes the group will check on his own, will be automatically deleted

  

 3, re-create the user: xiaodi

[root @ localhost Home] # useradd Xiaodi 
Creating Mailbox File: file already exists 
useradd: Warning: This home directory already exists. 
Do not copy any files to it from skel directory. 
[Home the root @ localhost] # Xiaodi ID 
UID = 609 (Xiaodi) GID = 611 (Xiaodi) Groups = 611 (Xiaodi) = the root context: system_r: unconfined_t: SystemLow- SystemHigh 
[Home the root @ localhost] #

 

 4, the analog switch user lost pattern

  When the user login, style becomes -bash-4.2 $, you need to execute the command, copying the style format: cp /etc/skel/.* / home / xiaodi

 

5, to add a group to another user xiaodi bigdata

[root@localhost ~]# groupadd bigdata
[root@localhost ~]# cat /etc/group |grep bigdata
bigdata:x:612:
[root@localhost ~]# usermod -a -G bigdata xiaodi
[root@localhost ~]# id xiaodi
uid=609(xiaodi) gid=611(xiaodi) groups=611(xiaodi),612(bigdata) context=root:system_r:unconfined_t:SystemLow-SystemHigh
[root@localhost ~]#

 

  6, the main modifications to bigdata group of xiaodi

[root@localhost ~]#  usermod -a -G bigdata xiaodi
[root@localhost ~]# id xiaodi
uid=609(xiaodi) gid=611(xiaodi) groups=611(xiaodi),612(bigdata) context=root:system_r:unconfined_t:SystemLow-SystemHigh
[root@localhost ~]# usermod --gid  bigdata xiaodi
[root@localhost ~]# id xiaodi
uid=609(xiaodi) gid=612(bigdata) groups=612(bigdata) context=root:system_r:unconfined_t:SystemLow-SystemHigh
[root@localhost ~]# usermod -a -G xiaodi xiaodi
[root@localhost ~]# id xiaodi
uid=609(xiaodi) gid=612(bigdata) groups=612(bigdata),611(xiaodi) context=root:system_r:unconfined_t:SystemLow-SystemHigh
[root@localhost ~]# 

  

 7, set a password

[root@localhost ~]# passwd xiaodi
Changing password for user xiaodi.
New UNIX password: 
BAD PASSWORD: it is too simplistic/systematic
Retype new UNIX password: 
passwd: all authentication tokens updated successfully.
[root@localhost ~]# 

 

8, the user switches

[root@localhost ~]# su - xiaodi
[xiaodi@localhost ~]$ 

    Xiaodi su
    su - Xiaodi
        on behalf of switching the user's home directory, and the execution environment variable file

  . Bash_profile file su xiaodi not be executed, su - xiaodi perform
  .bashrc file su xiaodi execution, su - xiaodi perform

 

9, the average user to obtain maximum root privileges

vi /etc/sudoers
xiaodi    ALL=(root)      NOPASSWD:ALL

 

 

 

 

Two, sudo command

  For ordinary users sometimes encounter: "ls: can not open directory:. Permission denied" question authority, indicating that the average user is currently running instruction root super administrator privileges, if for the average user, non to run this command, you can add keywords to sudo in front of the instruction.

 

 

Third, the user can not log passwd file

Fourth, the permissions rwx ------ chmod chown Case

  Error: Permission denied

    · Chmod -R 777 folder / file path
    · chown -R User: a user group folder / file path

  Permissions for the file or folder identification purposes: D represents Folder - l represents the file represented connector
    as: rwx rx rx

        R & lt: Read. 4
        W: Write 2
        X: execution. 1
        : - no authority 0

          7=rwx
          3=wx
          5=rx

    The first group of users rwx 7 represents the root of the file or folder, performing read and write
    the user set the root rx 5 represents a second group of files or folders, the read execution
    rx 5 represents a third set of other groups of users belong to the file or folder permissions: read execution

    d rwx r-x r-x 2 root root 6 Nov 16 22:15 xiaodi

  chmod -R 777 folder / file path
  chown -R user: a user group folder / file path

    777 represents any of the users in the group have execute permissions to read and write

  

 

  Example:

[root@localhost ~]# cd /tmp/
[root@localhost tmp]# ll
总计 108
drwx------ 3 linux linux 4096 11-10 22:04 gconfd-linux
drwx------ 2 linux linux 4096 10-16 06:12 keyring-auFdRo
drwx------ 2 linux linux 4096 10-16 06:01 keyring-AY1zU5
drwx------ 2 linux linux 4096 11-10 22:04 keyring-d9Zc9n
drwx------ 2 linux linux 4096 11-01 05:06 keyring-Gg6isH
drwx------ 2 linux linux 4096 10-23 00:45 keyring-GJV1cR
drwx------ 2 linux linux 4096 10-15 21:34 keyring-O34ivV
drwx------ 2 linux linux 4096 10-25 20:03 keyring-x5O2gc
srwxrwxr-x 1 linux linux    0 11-10 22:04 mapping-linux
drwx------ 2 linux linux 4096 11-22 00:22 orbit-linux
-rw-rw-r-- 1 linux linux    5 11-22 01:22 scim-bridge-0.3.0.lockfile-500@localhost:0.0
srwxrwxr-x 1 linux linux    0 11-22 00:22 scim-bridge-0.3.0.socket-500@localhost:0.0
srw------- 1 linux linux    0 11-10 22:04 scim-helper-manager-socket-linux
srw------- 1 linux linux    0 11-10 22:04 scim-panel-socket:0-linux
srw------- 1 linux linux    0 11-10 22:04 scim-socket-frontend-linux
drwx------ 2 linux linux 4096 11-10 22:04 ssh-uUAfXg5534
[root@localhost tmp]# echo "https://www.cnblogs.com/Raodi" >> rz.log
[root@localhost tmp]# ll |grep rz
-rw-r--r-- 1 root  root    30 11-22 01:59 rz.log
[root@localhost tmp]# su - xiaodi
[xiaodi@localhost ~]$ cd /t
tftpboot/ tmp/      
[xiaodi@localhost ~]$ cd /tmp/
[xiaodi@localhost tmp]$ ll |grep rz
-rw-r--r-- 1 root  root    30 11-22 01:59 rz.log
[xiaodi@localhost tmp]$ vi rz.log
https://www.cnblogs.com/Raodi
a
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
[xiaodi@localhost tmp]$ ll -a
总计 176
drwxrwxrwt 15 root  root  4096 11-22 02:01 .
drwxr-xr-x 24 root  root  4096 11-10 22:04 ..
drwxrwxrwt  2 root  root  4096 11-10 22:04 .font-unix
drwx------  3 linux linux 4096 11-10 22:04 gconfd-linux
-rw-------  1 linux linux   66 11-22 00:25 .gdmD7A9A0
srw-rw-rw-  1 root  root     0 11-10 22:04 .gdm_socket
drwxrwxrwt  2 root  root  4096 11-10 22:04 .ICE-unix
drwx------  2 linux linux 4096 10-16 06:12 keyring-auFdRo
drwx------  2 linux linux 4096 10-16 06:01 keyring-AY1zU5
drwx------  2 linux linux 4096 11-10 22:04 keyring-d9Zc9n
drwx------  2 linux linux 4096 11-01 05:06 keyring-Gg6isH
drwx------  2 linux linux 4096 10-23 00:45 keyring-GJV1cR
drwx------  2 linux linux 4096 10-15 21:34 keyring-O34ivV
drwx------  2 linux linux 4096 10-25 20:03 keyring-x5O2gc
srwxrwxr-x  1 linux linux    0 11-10 22:04 mapping-linux
drwx------  2 linux linux 4096 11-22 00:22 orbit-linux
-rw-r--r--  1 root  root    30 11-22 01:59 rz.log
-rw-rw-r--  1 linux linux    5 11-22 01:22 scim-bridge-0.3.0.lockfile-500@localhost:0.0
srwxrwxr-x  1 linux linux    0 11-22 00:22 scim-bridge-0.3.0.socket-500@localhost:0.0
srw-------  1 linux linux    0 11-10 22:04 scim-helper-manager-socket-linux
srw-------  1 linux linux    0 11-10 22:04 scim-panel-socket:0-linux
srw-------  1 linux linux    0 11-10 22:04 scim-socket-frontend-linux
drwx------  2 linux linux 4096 11-10 22:04 ssh-uUAfXg5534
-r--r--r--  1 root  root    11 11-10 22:04 .X0-lock
drwxrwxrwt  2 root  root  4096 11-10 22:04 .X11-unix
[xiaodi@localhost tmp]$ su -
口令:
[root@localhost ~]# cd /tmp/
[root@localhost tmp]# ll |grep rz
-rw-r--r-- 1 root  root    30 11-22 01:59 rz.log
[root@localhost tmp]# chmod 646 rz.log
[root@localhost tmp]# ll |grep rz
-rw-r--rw- 1 root  root    30 11-22 01:59 rz.log
[root@localhost tmp]# chmod 644 rz.log
[root@localhost tmp]# usermod -a -G root xiaodi
[root@localhost tmp]# ll |grep rz
-rw-r--r-- 1 root  root    30 11-22 01:59 rz.log
[root@localhost tmp]# chmod 664 rz.log
[root@localhost tmp]# ll |grep rz
-rw-rw-r-- 1 root  root    30 11-22 01:59 rz.log
[root@localhost tmp]# usermod -a -G root xiaodi
[root@localhost tmp]# ll |grep rz
-rw-rw-r-- 1 root  root    30 11-22 01:59 rz.log
[root@localhost tmp]# su - xiaodi
[xiaodi@localhost ~]$ cd /tmp/
[xiaodi@localhost tmp]$ ll |grep rz
-rw-rw-r-- 1 root  root    30 11-22 01:59 rz.log
[xiaodi@localhost tmp]$ echo "sads">>rz.log 
[xiaodi@localhost tmp]$ cat rz.log 
https://www.cnblogs.com/Raodi
sads
[xiaodi@localhost tmp]$ 
User and file permissions

  ctrl + x / z will produce swp ll -a file can be deleted .rz.log.swp

  

 

Five other command

  1, view the file size

[xiaodi@localhost tmp]$ ll |grep rz
-rw-rw-r-- 1 root  root    35 11-22 02:05 rz.log
[xiaodi@localhost tmp]$ du -sh rz.log
8.0K    rz.log
[xiaodi@localhost tmp]$ 

 

 2, View Folder Size

[root@localhost ~]# cd /tmp/
[root@localhost tmp]# ll |grep rz.log 
-rw-rw-r-- 1 root   root      35 11-22 02:05 rz.log
[root@localhost tmp]# mkdir bs
[root@localhost tmp]# mv rz.log bs/
[root@localhost tmp]# du -sh bs/
16K     bs/
[root@localhost tmp]# 

 

 3. Search find 

   history history
   ps -ef see the process
   top system case

[root@localhost tmp]# cd /usr/local/
[root@localhost local]# mkdir xxxhadoopxxx
[root@localhost local]# mkdir hadoop
[root@localhost local]# find / -name '*hadoop*'
/usr/local/xxxhadoopxxx
/usr/local/hadoop
find: /proc/fs/vmblock/mountPoint: 没有那个文件或目录
[root@localhost local]# find /usr/local -name '*hadoop*'
/usr/local/xxxhadoopxxx
/usr/local/hadoop
[root@localhost local]# 

  * Represents the fuzzy matches

 

 

Guess you like

Origin www.cnblogs.com/Raodi/p/11909441.html