06. LINUX commands(5) - Uchiha3000/LINUX_docx GitHub Wiki

LINUX commands part-5

What is drwxr-xr-x?

Ans: When we use long list (i.e. ls -l) we get this "drwxr-xr-x". This are permission for read, write and execute. r-read, w-write and x-execute.

  1. rwx- This first set of rwx represents owner. He is the one who created the file. To find the owner type ls -l. In this example the owner is first "ec2-user". Lets take a real life example. Suppose a person from a IT group created a document he is the owner. Only he has the rwx permission (i.e. read, write and execute permission).

  2. rwx- This second set of rwx represents group user. In this example the group user is second "ec2-user". The other persons in the IT group are the group user. They have the permission of r-x permission (i.e. read and execute permission).

  3. rwx- This third set of rwx represents public. In the real life example we are taking lets suppose one guy works in the account he is the public. He has r-x permission (i.e. read and execute permission).

[Note: In "drwxr-xr-x" d is for directory, the next three characters are the permission for owner "drwxr-xr-x". The next three characters are the permission for public user "drwxr-xr-x". Finally the last three characters are the permission for public "drwxr-xr-x"]

What is the value of read, write and execute?

Ans: r=4, w=2 & x=1. Their total is 7.

How to give permission in files?

Step 1: Create a file. code: touch dummy

Step 2: Give permission accordingly. code: chmod 765 dummy

[Note: chmod is the command for giving permissions. The three numbers represents owner, group user and public. Now owner has 7, so 4+2+1 means he has read, write and execute permission. Group user has 6, so 4+2 means he has read and write permission. Lastly public has 5, so 4+1 means he has read and execute permission.]

How to give all permission of a file to everyone?

code: chmod 777 dummy

How to give all permission of a directory to everyone?

Step 1: Make a directory named "dummy".

code: chmod 777 dummy

[Note: -R is for recursive]

[Note: Only the owner can change the permissions of a file.]

How to check which latest applications are running on my LINUX?

code: ps -ef

How to check all the applications that are running on my LINUX?

code: ps -ef | more

[Note: UID is User ID, PID is Process ID, PPID is Parent Process ID, TTY is Terminal name, **TIME **is for showing the time at which the execution of the command started. Finally the **CMD ** stands for command.]

How to check my terminal name?

code: tty

[Note: Everyone and every time there will be a new terminal name. Whenever we connect a server to a terminal the system will generate a name for that terminal.]

How to check which commands are used since the server started running?

code: history

How to check how many "ls -rtl" command are used since the server started running?

code: history | grep "ls -rtl"

How to check how many times the "ls -rtl" command are used since the server started running?

code: history | grep "ls -rtl" | wc -l

How to check all commands options for ls command?

code: man ls

How to display the text "Hello World" on screen?

code: echo "Hello World"

How to force stop a application or process?

code: kill -9 3845729

[Note: kill space -9 space process id]