Mastery On Linux
Mastery On Linux
General Linux
home :→ This is the home directory, it contains all the user specific folders.
home/<userName> :→ This is a directory under home directory which contains .bashrc &
.profile files for respective users.
General Information
Get help of any command :- man <command-name>
Keyboard Shortcut
Logout from the current user account or end session :- ctrl + D or exit
User Management
Add a new user :- sudo adduser <username> . It add a new user. After adding user we can
add that user to "sudo" group to give that user sudo privilege.
Add a new user to a specific group :- sudo adduser <userName> <groupName> . It adds the
user to the mentioned group.
Remove a user :- sudo deluser --remove-home? <userName> it delete the mentioned user
with it's home directory (Optional).
Add a new user group :- sudo addgroup <groupName> it add a new group.
Remove a user group :- sudo delgroup <groupName> it removes the mentioned group.
Activate root user mode :- sudo -i , it activates the root user mode which changes the $
sign to # sign. This command works only if a password is set for root user.
Operate with root privilege from a user :- sudo ...rest of the command
Tar zip
Make a tar zip from a source folder - tar -cvf <filename.tar> <SourceFolder>.
Unzip a tar zip file - tar -xvf <filename.tar>
Set default user to root from CMD. ubuntu<version without dot> config -–default-
user root
Go to Linux terminal and change password for target user. passwd <userName>
Set default user to target user from CMD. ubuntu<version without dot> config -–
default-user <userName>
sudo nano /etc/hosts and replace all the occurrence of old host name with new
one.
Terminate ubuntu instance from CMD > wsl -t <instanceName>
Relaunch after 8 seconds.
To work with space or dash containing file/folder name we should enclose it within a
quote.
Operations
[options]
-r recursive
-f force
List out all the available cron-tab for current user:- crontab -l .
List out all the available cron-tab for any user:- crontab -u <userName> -l . To do this
must have root privilege.
Add a new crontab job using any editor for current user :- crontab -e
Add a new crontab job using any editor for any user:- crontab -u <userName> -e To do
this must have root privilege.
To set custom email address :- add MAILTO = "[email protected]" at the top of cron file.
Starts finding from startDir directory, name to search for , for multiple name used -o, checks if
empty, finding type directory or file.