Basic Linux Commands

ยท

3 min read

Today I have done Hands-On on Some Very basic Linux Commands which we use in our day-to-day Working day.

  1. ๐Ÿ“‚(Present Working Directory)pwd: This command uses the "pwd" Command to check the present working directory this command will let you know your present directory

  2. ls -a: "ls" command will show you only the list of files and directories but when you write "ls -a" it will help you to show all files and directories including hidden files and directories

  3. ๐Ÿ“‚mkdir -p A/B/C/D/E: " mkdir" command will create a directory but if you want to create a nested directory then use this command **"mkdir -p A/B/C/D/E "**where the "-p" option is used to create parent directories as needed.

  4. cat <filename>: To view what's written in a file

  5. chmod [options] permissions file(s): To change the access permissions of files in Linux, you can use the "chmod" command

    for Example :

    • chmod 755 filename: To give read, write, and execute permissions to the owner, and only read permissions to others

    • chmod 644 filename: To give read and write permissions to the owner, and only read permissions to the group and others

  6. history: you can use the history command to view the list of commands you have run in the current session. The history command displays a numbered list of previously executed commands along with their command numbers. Here's how you can use it

  7. rm: To remove or delete the files/directory

  8. touch: To create a file named "fruits.txt" and view its contents, you can use the " touch fruits.txt "

  9. head -3: To Show only the top three lines from the file.

  10. tail -3: To Show only the bottom three lines from the file.

  11. Ping: This command will ping a host and check if it is responding.

  12. ifconfig: This is used to configure the kernel-resident network interfaces

Special Files Permissions :

SUID (Set User Id): If SUID is set on an executable file and a normal user executes it then the process will have the same rights as the owner of the file being executed instead of the normal user. (Eg: password command)

## suid applied on user permission so u+s.

## "S" denotes suid applied on the file .

SGID(Set Group Id): If SGID is set on any directory, all subdirectories and files created inside will get the same group ownership as the main directory, it doesn't matter who is creating.

#mkdir gulshan

#chmod g+s gulshan/

#ls -ltr

## sgid applied on group permission so g+s(We can use g+2 also).

STICKY BIT: it is used on folders in order to avoid deletion of a folder and its content by other users though they have written permissions on the folder contents. Except for the owner and root user, No one can delete other users' data in this folder(Where the sticky bit is set). though other users have full permission.

## It applid on other permission so o+t.

## Hear "t" is for sticky bit . As execute permission is there for other so its showing "t" instead of "T".

ย