Explain some more commands in Linux

To know the package install and who is installed

which <package name>

To know who you are (like,. Root or ec2-user)

 whoami 

Long List cmd:

ls -l  or  ll

Find operation:

Current directory  files display

find -type f (f-file) 

Current directory display directories:

find -type d (d- directory)
find / -type f -name passwd

Add user for Login (IAM User):

useradd username

See user login:

cat /etc/passwd

Add group :

groupadd group name

Add user into group:

gpasswd -a <username> <groupname> (a is single user)
gpasswd -m <username>, <username1> <groupname> (m is multiple user)

Softlink (in windows “shortcut”):

ln -s <filename> <short linkname>

Note: original file will be removed, shortlink file also removed.

Hardlink :

ln <filename> <harlinkname>

note : if incase original file is removed. Available in hardlink file full data.

Compress the file:

tar -cvf <directory/filename.tar> <filename>

(cvf: v- verbose)

Change zip formate compress file:

gzip <compress filename>

Uncompress the compressed file:

gunzip  <filename .tar.gz>
tar -xvf <compressname.tar> 

How to install local system file to linux:

Download file and copy the url link below the filename

wget  <paste the link>
 yum install <full filename> -y

Total delete from current directory:

rm -rf *

Long list:

ls -l /  ll

drwxr-xr-xr-x 2 root root 6 Feb 22 15:56 <directory name>

-rw-r–r– 1 root root 0 Feb 22 15:58 <filename>

For examples
  • “d” denotes directory
  • “-” denotes file
rwx -1r-x -2r-x -3
rwr–r–
  User/root                       Group() other users

   

Read : (r)  – 4

Write : (w) – 2

Execute : (x) – 1

Ex: 

Directory: Default permissions for directory (755).

rwe – 4+2+1 = 7

rx- 4+1 = 5

rx – 4+1 = 5

File: default permission for file (644)

rw- 4+2 = 6

r- 4 = 4

r- 4 = 4

chmod  777 <directory name>

[7- root/user, 7- group, 7-others]

chmod 444 <filename>

chown <username> <directory name>

chgrp <group name> <directory name>

chmod 777 <directory name>

chmod 666 <directory name>

chmod 700 <directory name>

chmod 765 <filename>

Leave a Reply

Your email address will not be published.