Skip to content

Instantly share code, notes, and snippets.

@Monmoy042
Last active August 3, 2021 14:59
Show Gist options
  • Save Monmoy042/0f101965e5a4b9f4e2a4998f45e60d8b to your computer and use it in GitHub Desktop.
Save Monmoy042/0f101965e5a4b9f4e2a4998f45e60d8b to your computer and use it in GitHub Desktop.

Print the present working directory

pwd

Check Date and Calendar

Show current time and date: date
Show calendar: cal
Show particular year's calendar: cal 2021

Show which user currently logged in to the system

who
whoami

Show hosname/name of the pc or system

hostname

Show OS name/Kernel Version/GUI or terminal type

uname
uname -r
runlevel

Show uptime/login details/free memory/ip address info

uptime
lastlog
free -m
ifconfig or ip addr

Show command history/list of command history

Check command history: history
Run 36th command from history list: !36 
Delete all commands from history list: history -c 

List

Show short list: ls
Show long list: ll
Show long list: ls -l
Show list with hidden files/directory: ls -al
Show files/directory size with himan readable compatability: ls -lh
Show list with inode: ls -i
Show combination of list: ls -ali
Show combination of list: ls -alih

Change Diretory

Go to home directory: cd ~
Go to root partition: cd /
Go to root home directory: cd /root
Go to one step back from the current directory: cd ../
Go to two step back from the current directory: cd ../../
cd [directoryName]
cd [directoryName/dir1/dir2]
Go to the previous directory: cd -

Create new directory

mkdir [directoryName]
Create Multiple directory: mkdir [dir1 dir2 dir3]
Create Multiple directory: mkdir dir{4..7}
Create sub-directory: mkdir dir1/dir2
Create sub-directory: mkdir -p /dir1/dir2/myDir
Create multiple sub-directory: mkdir -p dir1/{dir2,dir3,dir4}
Create hidden directory: mkdir .hidDir

Create new files

Create single file: touch file1.txt
Create multiple files: touch file2.txt file3.txt
Create multiple files: touch test{1..5}.txt
Create multiple files: touch myFile{5,8,9}.txt
Create multiple files: touch file-{tamim,sakib,mash}.txt
Create multiple files: touch {app,index,main}.js
Create file in a particular directory: touch /dir1/newFile.txt
Create hiddne file: touch .hidFile

Copy/Paste/Remove/Rename/Move/Delete

Copy file: cp [fileName] [newFileName]
Copy file in a particular directory: cp file1 /home/dir1/dir2/file2
Copy file from another location to present location: cp /etc/passswd .
Copy a directory: cp -r [present directory name] [new directory name]
Rename a file: mv file1 myFile
move file: mv myFile ./dir1
Remove/Delete file: rm [fileName]
Remove/Delete directory: rm -r [directoryName]
Remove/Delete directory: rm -rf [directoryName]
Remove/Delete directoey, if directory is empty: rmdir [directoryName]
Remove all contents from the present directory: rm -rf *
Delete directory with all sub-directory and files: rm -rv [parent directoryName]

Disk Usage Information

Show disk usage: du
Show disk usage human readable: du -h
Show disk usage human readable and summarize: du -sh
Show disk usage aith all info: du -a
Show disk usage with all: du -ah
Show total disk usage size: du -ch

Show Directory Size

du -sh *
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment