Ubuntu Terminal - Commands for User Groups, Directory, Permissions and Ownership

When you are working on Ubuntu/Linux OS, some important command given below can help you in managing Users groups and directories.
1. Check user-groups, a user account belongs to:
$ groups

2. Add new user-group
$ sudo groupadd user-group-name

3. Add user-account to a user-group:
$ sudo usermod -a -G examplegroup exampleusername
OR
$ usermod -a -G group1,group2,group3 exampleusername

4. Change user account’s primary group:
$ usermod -g groupname username

5. To change ownership of a folder:
$ sudo chown -R www-data:www-data /var/www/
OR
$ sudo chown -R $USER:$USER /var/www/example.com/public_html

$USER will take account of the current user logged in.

6. Check permissions to specific directory:
$ ls -ld /directory/

7. Link command (creating shortcut):
$ sudo ln file1.txt file2.txt
or we can also use ln to create symbolic links with the -s option
$ sudo ln -s file1.txt file2.txt

Comments

Popular posts from this blog

Using Virtual Columns in Laravel - Accessors and Appends

How to Show Cookie Policy Consent or GDPR Popup in Laravel using Cookie.

Postman Collection Run - How to Test File Uploading API on CircleCi or Jenkins