$ sudo groups jack $ sudo usermod -G sudo jack $ sudo groups jack
$ sudo deluser jack –remove-home
- To display all files except the
.
(current directory) and..
(parent directory):
$ ls -A
- To use both the -A and -l parameters together:
$ ls -Al
- To view the full properties of a directory:
$ ls -dl <directory>
- To show all the file sizes:
$ ls -AsSh
touch iphonex
The file owner is jack:
Then we switch the user to « labex » . We can use the following command to change the file owner for « labex »:
$ cd /home/jack $ ls iphonex $ sudo chown labex iphonex
Find the file owner modified successfully for labex:
- Method 1:Binary number representation
Each file has three groups of permissions (owner, user group, others) corresponding to a « rwx » triplet. The file « iphonex » permissions are changed to « only for owner to use »:
In order to demonstrate, we write some words into the file:
$ echo "echo \"hello labex\"" > iphonex
Then modify the permissions:
$ chmod 700 iphonex
Now, other users are unable to read this « iphonex » file.
- Method 2:Addition and subtraction assignments
You can use the following command to achieve the same result as by method 1:
$ chmod go-rw iphonex
u
, g
and o
respectively represent user (file owner), group and others. +
and -
represent to add and remove the corresponding permissions.
What is the difference between useradd
and adduser
?
The command useradd
can only create the user. After that, we need to use passwd
to set up password for the new user. The command adduser
not noly creates a user, but also creates a directory, and a password.