[2] Manage File,dir,user,group

Source: Internet
Author: User

Root Directory introduce:

Dev:device Directory
Etc:system software Startup and config
Home:user Main Directory
Lib:c complier directory/libary
Mnt:host Plug/unplug Device
Proc:system directory, Process infomation
Root:super User Main Directory
Tmp:temp file


sudo is a shorthand for superuser do, and Sudo is a Linux system Management Directive, a tool that allows the system administrator to let ordinary users perform some or all of the root commands, such as HALT,REBOOT,SU and so on. This not only reduces the login and administration time of the root user, but also improves security.

Apt is a complete and advanced software package management program that allows you to find the package you want, simple and accurate, with simple installation or uninstallation. He also has the ability to update any of your software to the latest state, and can also be used to upgrade Ubuntu.


Basic Command:

Mkdir
[Email protected]:~$ mkdir test2 test3--create-diretories
[Email protected]:~$ mkdir test1/mydir--create a folder under Test1

[Email protected]:~$ mkdir Test100/mydir
Mkdir:cannot Create directory ' Test100/mydir ': No such file or directory
[Email protected]:~$ mkdir-p test100/mydir-Force create the folders, if test100 doesn ' t exist

Touch
[Email protected]:~$ Touch Hello--Create The hello file in current directory

Echo
[Email protected]:~/test1$ cat Hellobackup
[Email protected]:~/test1$ echo "Hello" > Hellobackup--Write "Hello" to the file
[Email protected]:~/test1$ cat Hellobackup
Hello

Mv
[Email protected]:~$ mv Hello test1--Move Hello to Test1 folder
[Email protected]:~/test1$ mv Hello hellobackup--Rename a file.

Cp
[Email protected]:~$ cp pse2 test2--Copy file Pse2 to Test2 folder

Rm/rmdir
[Email protected]:~$ rm Hello--Remove Hello File
[Email protected]:~$ rmdir test2--Remove Test2 folder

[Input] Redirect:
[Email protected]:~$ cat <<eof >hellobackup
> Hello world!
> Real Func
> EOF
[Email protected]:~$ cat Hellobackup
Hello world!
Real Func
[Email protected]:~$


|------Example (create,remove file)--------|
[Email protected]:~$ cd Mhydir
[Email protected]:~/mhydir$ ls
[Email protected]:~/mhydir$ Touch Test
[Email protected]:~/mhydir$ ls
Test
[Email protected]:~/mhydir$ RM Test
[Email protected]:~/mhydir$ ls
[Email protected]:~/mhydir$ Touch Test
[Email protected]:~/mhydir$ rm-i Test--will Confirm whether delete the file
Rm:remove Regular empty file ' test '? N
[Email protected]:~/mhydir$ ls
Test
[Email protected]:~/mhydir$ rm-i Test
Rm:remove Regular empty file ' test '? Y
[Email protected]:~/mhydir$ ls
[Email protected]:~/mhydir$
|--------End-----------|



File Permission:
Drwxr-xr-x 2 Tangym tangym 4096
[LinkCount]    [CurrentUser]   [CurrentGroup]  [FileSize] [CreationTime]
Field1:self permission
drwxr-
D:direcory
Rwx:read,write,execute,

Field2:current group ' s user permission
R-x:

Field3:other group ' s user permission
R-x


|------Change file owner and Workgroup-----|
[Email protected]:~$ mkdir Mvhello
[Email protected]:~$ ls-l Mvhello
Total 0
[Email protected]:~$ ls-l
Total 204136
Drwxr-xr-x 2 Tangym tangym 4096
Drwxr-xr-x 2 Tangym tangym 4096
Drwxr-xr-x 3 Tangym tangym 4096 08:53 Downloads
-rw-r--r--1 tangym tangym 8445 examples.desktop
-rw-rw-r--1 tangym tangym 10240 Jan ez_setup.py
Drwxrwxr-x 2 Tangym tangym 4096 may 23:37 Mhydir
Drwxr-xr-x 2 Tangym tangym 4096
drwxrwxr-x 2 Tangym tangym 4096 may 23:49 Mvhello
Drwxr-xr-x 2 Tangym tangym 4096 Pictures
-rw-rw-r--1 tangym tangym 0 may 22:42 PSE
-rw-rw-r--1 tangym tangym 0 may 23:12 Pse2
Drwxr-xr-x 2 Tangym tangym 4096
Drwxrwxr-x 9 Tangym tangym 4096 08:18 pycharm-community-2016.1.3
-rwxrw-rw-1 tangym tangym 207707566 08:09 pycharm-community-2016.1.3.tar.gz
Drwxrwxr-x 3 Tangym tangym 4096 08:25 pycharmprojects
Drwxrwxr-x 6 Tangym tangym 4096 08:55 redis-2.8.12
-rw-rw-r--1 tangym tangym 1215331 June redis-2.8.12.tar.gz
Drwxrwxr-x Tangym tangym 4096, 08:54 Redis-py-master
Drwxr-xr-x 2 Tangym tangym 4096 Templates
Drwxrwxr-x 3 Tangym tangym 4096 may 23:11 test1
Drwxrwxr-x 3 Tangym tangym 4096 may 22:38 test100
Drwxrwxr-x 2 Tangym tangym 4096 may 22:36 test3
Drwxrwxr-x 2 tangym tangym 4096 21:52 TestFolder
Drwxrwxr-x 2 Tangym tangym 4096, Ubuntu one
-rw-rw-r--1 tangym tangym 0 may 21:49 Untitled Document
Drwxr-xr-x 2 Tangym tangym 4096 Videos
DRWXRWX---2 Lewis workgroup 4096 may 22:25 work
[Email protected]:~$sudo chown Lewis Mvhello
[sudo] password for tangym:
[Email protected]:~$ ls-l
Total 204136
Drwxr-xr-x 2 Tangym tangym 4096
Drwxr-xr-x 2 Tangym tangym 4096
Drwxr-xr-x 3 Tangym tangym 4096 08:53 Downloads
-rw-r--r--1 tangym tangym 8445 examples.desktop
-rw-rw-r--1 tangym tangym 10240 Jan ez_setup.py
Drwxrwxr-x 2 Tangym tangym 4096 may 23:37 Mhydir
Drwxr-xr-x 2 Tangym tangym 4096
drwxrwxr-x 2 Lewis tangym 4096 may 23:49 Mvhello
Drwxr-xr-x 2 Tangym tangym 4096 Pictures
-rw-rw-r--1 tangym tangym 0 may 22:42 PSE
-rw-rw-r--1 tangym tangym 0 may 23:12 Pse2
Drwxr-xr-x 2 Tangym tangym 4096
Drwxrwxr-x 9 Tangym tangym 4096 08:18 pycharm-community-2016.1.3
-rwxrw-rw-1 tangym tangym 207707566 08:09 pycharm-community-2016.1.3.tar.gz
Drwxrwxr-x 3 Tangym tangym 4096 08:25 pycharmprojects
Drwxrwxr-x 6 Tangym tangym 4096 08:55 redis-2.8.12
-rw-rw-r--1 tangym tangym 1215331 June redis-2.8.12.tar.gz
Drwxrwxr-x Tangym tangym 4096, 08:54 Redis-py-master
Drwxr-xr-x 2 Tangym tangym 4096 Templates
Drwxrwxr-x 3 Tangym tangym 4096 may 23:11 test1
Drwxrwxr-x 3 Tangym tangym 4096 may 22:38 test100
Drwxrwxr-x 2 Tangym tangym 4096 may 22:36 test3
Drwxrwxr-x 2 tangym tangym 4096 21:52 TestFolder
Drwxrwxr-x 2 Tangym tangym 4096, Ubuntu one
-rw-rw-r--1 tangym tangym 0 may 21:49 Untitled Document
Drwxr-xr-x 2 Tangym tangym 4096 Videos
DRWXRWX---2 Lewis workgroup 4096 may 22:25 work
[Email protected]:~$ whatis chgrp
CHGRP (1)-Change group ownership
[Email protected]:~$sudo chgrp workgroup Mvhello
[Email protected]:~$ ls-l
Total 204136
Drwxr-xr-x 2 Tangym tangym 4096
Drwxr-xr-x 2 Tangym tangym 4096
Drwxr-xr-x 3 Tangym tangym 4096 08:53 Downloads
-rw-r--r--1 tangym tangym 8445 examples.desktop
-rw-rw-r--1 tangym tangym 10240 Jan ez_setup.py
Drwxrwxr-x 2 Tangym tangym 4096 may 23:37 Mhydir
Drwxr-xr-x 2 Tangym tangym 4096
drwxrwxr-x 2 Lewis workgroup 4096 may 23:49 Mvhello
Drwxr-xr-x 2 Tangym tangym 4096 Pictures
-rw-rw-r--1 tangym tangym 0 may 22:42 PSE
-rw-rw-r--1 tangym tangym 0 may 23:12 Pse2
Drwxr-xr-x 2 Tangym tangym 4096
Drwxrwxr-x 9 Tangym tangym 4096 08:18 pycharm-community-2016.1.3
-rwxrw-rw-1 tangym tangym 207707566 08:09 pycharm-community-2016.1.3.tar.gz
Drwxrwxr-x 3 Tangym tangym 4096 08:25 pycharmprojects
Drwxrwxr-x 6 Tangym tangym 4096 08:55 redis-2.8.12
-rw-rw-r--1 tangym tangym 1215331 June redis-2.8.12.tar.gz
Drwxrwxr-x Tangym tangym 4096, 08:54 Redis-py-master
Drwxr-xr-x 2 Tangym tangym 4096 Templates
Drwxrwxr-x 3 Tangym tangym 4096 may 23:11 test1
Drwxrwxr-x 3 Tangym tangym 4096 may 22:38 test100
Drwxrwxr-x 2 Tangym tangym 4096 may 22:36 test3
Drwxrwxr-x 2 tangym tangym 4096 21:52 TestFolder
Drwxrwxr-x 2 Tangym tangym 4096, Ubuntu one
-rw-rw-r--1 tangym tangym 0 may 21:49 Untitled Document
Drwxr-xr-x 2 Tangym tangym 4096 Videos
DRWXRWX---2 Lewis workgroup 4096 may 22:25 work


[Example-------Create Users and share Group-----]
---Create workgroup----
[Email protected]:~$ sudo groupadd Workgroup
[sudo] password for tangym:

---Create four users and password----
[Email protected]:~$ sudo useradd -G workgroup Lucy
[Email protected]:~$ sudo passwd Lucy
Enter New UNIX Password:
Retype new UNIX Password:
Passwd:password updated successfully

[Email protected]:~$ sudo useradd-g workgroup Lewis
[Email protected]:~$ sudo passwd Lewis
Enter New UNIX Password:
Retype new UNIX Password:
Passwd:password updated successfully

[Email protected]:~$ sudo useradd-g workgroup Mike
[Email protected]:~$ sudo passwd mike
Enter New UNIX Password:
Retype new UNIX Password:
Passwd:password updated successfully

[Email protected]:~$ sudo useradd-g workgroup Peter
[Email protected]:~$ sudo passwd Peter
Enter New UNIX Password:
Retype new UNIX Password:

-----Create direcories
[Email protected]:~$ cd/home
[Email protected]:/home$ sudo mkdir work--Create direcory
[Email protected]:/home$ sudo chgrp workgroup work--Update a directory belonged group.
[Email protected]:/home$ sudo chmod g+rwx work--g+ Rws:read,write,execute
[Email protected]:/home$ sudo chmod o-rwx work--O:other, remove other group ' s permission.
[Email protected]:/home$ sudo chown Lewis work-set the group leads to Lewis.



This article is from the "Software Design and Development" blog, please be sure to keep this source http://yuanzhitang.blog.51cto.com/2769219/1783023

[2] Manage File,dir,user,group

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.