Linux Command

cal - calendar
whoami - Whats your user name
who - who and all logged in this system
halt - Brings the System Down Immediately
shutdown - Shut Down the System
reboot - Reboot the System

File Management

ls ~ to list files
ls-l ~ to list all files with details
ls-a ~ to view hidden files
pwd ~ current location

vi  ~ Create File
 - edit mode (i)  
 - escape mode (esc)
   + :wq (save & quit)
   + :q! (quit without save)

cat  ~ Open file

Copy & Paste (with escape commands)

yy ~ copy the current line
dd ~ delete entire line
u ~ undo last change
3dd ~ to delete 3 lines
p ~ paste line
x ~ delete content

Search

/  ~ search text forward
?  ~ Search text backwards (from down to top)
:s /search/replace/g ~ replace words or group of words within your files

Copy File

cp <sourcefile> <destinationfile>
cp <sourcefile> Directory_name

Renaming or Moving File

mv <file1> <file2> ~ move or rename file
wc <file> ~ count of lines
rm <file> remove file
touch <filename> ~ create file

Directory

mkdir <foldername> ~ create folder
rmdir <foldername> ~ delete folder
rm -rf <foldername> ~ delete subfolder
cd ../.. ~ back double folder

Permission (users, groups, others)

r ~ read(4)
w ~ write(2)
e ~ execute (1)

chmod 777 <filename> ~ give all permission to all
chmod 700 <filename> ~ give all permission to only owner
chmod 774 <filename> ~ give read, write to own and group. Give only read permission to others
chmod 764 <filname> ~ Execute permission

Grep Command – To search a file or a string in a file

grep string <filename> (ex : grep good sample1)
ls-l | grep sam

Sort command – To sort content alphabetically or numerically

sort filename
-n  #numerically
-r  #reverse
-f  #upper case & lower case together
ex: sort -n sample1

System related & Process related commands

top ~ cpu process table
ps -f (or -ef) ~ process wise detail get
ps -ef | grep Python ~ get specific keyword

kill -9 PID ~ to kill a process

Admin
Linux is a multi-user operating system, which means that more than one user can use Linux at the same time. Linux provides a beautiful mechanism to manage users in a system. One of the most important roles of a system administrator is to manage the users and groups in a system.

Linux user
A user or account of a system is uniquely identified by a numerical number called the UID (unique identification number). There are two types of users – the root or super user and normal users. A root or super user can access all the files, while the normal user has limited access to files. A super user can add, delete and modify a user account. The full account information is stored in the /etc/passwd file and a hash password is stored in the file /etc/shadow.

Adding a New Group
To add a new group to the system, type the following at a shell prompt as root
# groupadd options group_name

Adding an Existing User to an Existing Group
Use the usermod utility to add an already existing user to an already existing group. Various options of usermod have different impact on user’s primary group and on his or her supplementary groups.

To override user’s primary group, run the following command as root:
~]# usermod -g group_name user_name

To override user’s supplementary groups, run the following command as root:
~]# usermod -G group_name1,group_name2,… user_name

Note that in this case all previous supplementary groups of the user are replaced by the new group or several new groups.

To add one or more groups to user’s supplementary groups, run one of the following commands as root:

~]# usermod -aG group_name1,group_name2,… user_name

Admin Url
Link 1

Leave a Reply

Your email address will not be published. Required fields are marked *