Linux | Unix | Most Used Commands

Directory Listing

clear

To CLEAR the screen

ls

LiSt all files & folders

ls -l

LiSt all files & folders with detaiLs

cd < folder >

Change Directory or folder

cd ..

Change to parent Directory

cat < filename >

View content of a file

File and Folder

mkdir < folder >

MaKe or create a new folder or DIRectory

rm < folder / file >

ReMove or delete the folder or file

rm -r < folder >

Recursively ReMove or delete all files and folders under it the given folder

rm -f < folder >

ReMove folder Forcefully without prompting for confirmation

mv < old_name > < new_name >

MoVe or rename a file or folder

cp < fource_file_name > < destination_folder_name >

CoPy a file

zip -r < filename >.zip < folder_name >

ZIP folder and it’s files Recursively

unzip < filename >.zip

UNZIP or extract contents of a zipped file

unzip -o < filename >.zip 

UNZIP and Overwrite existing files without prompting

NANO editor | better than VI editor

nano < filename >

Create a new file or Open an existing file

Ctrl + W

Search text within the file

Ctrl + \

Search & Replace text

Ctrl + X

Exit editor

Permission | Power User | Admin Commands

sudo < command >

run each command as root user

sudo -i

Turn on root user to run all following commands as root user

cat /etc/passwd

List all users

adduser < user_name >

Add a new user

userdel < user_name >

Delete a user

userdel -r < user_name >

Delete user along with user’s home directory

chmod -R < xxx > < filename >

Change file or folder permission (Recursively)
‘X’ is the permission value

cat /etc/group

View all groups

groupadd < group >

Add or create a new group

groups < user >

View the groups the user is a member of

chgrp < group > < filename >

CHange GRouP of a file for folder

usermod -a -G < group > < user >

Add user to a group

chown -R < user_name >:< group_name > < filename >

CHange OWNer and Group of file or folder (Recursively)

WHO

View WHO all are currently logged-in

Leave a Reply

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