Skip to content

Bash Basic Commands

  • Let’s learn Bash basic commands for day to day work.
  • We also call it Linux commands, or Terminal commands

  • pwd stands print working directory
Terminal window
pwd
  • cd stands for change directory
  • ~ Tilde stands for default home directory
Terminal window
cd ~
  • iwork/learn is a relative path where we want to go after change directory
Terminal window
cd iwork/learn
  • ls stands for list directory
Terminal window
ls
  • mkdir stands for Make Directory
Terminal window
mkdir <directory_name>
  • rm stands for remove
  • -rf are options r recursive f force,
Terminal window
rm -rf <directory_name>
  • Above command means delete the folder and all its files and sub folders recursively and don’t ask for permission hence force used
CommandDescriptionExample
lsList directory contentsls -la
cdChange directorycd ~/Documents
pwdPrint working directorypwd
mkdirCreate a new directorymkdir new_folder
rmRemove files/directoriesrm file.txt
cpCopy files/directoriescp file.txt backup/
mvMove/rename filesmv old.txt new.txt
catDisplay file contentcat file.txt
grepSearch text patternsgrep "search" file.txt
findSearch for filesfind . -name "*.txt"
chmodChange file permissionschmod +x script.sh
psDisplay running processesps aux
killTerminate processeskill 1234
topDisplay system processestop
dfDisk space usagedf -h
duDirectory space usagedu -sh *
headShow first lines of filehead -n 10 file.txt
tailShow last lines of filetail -f log.txt
wcWord countwc -l file.txt
tarArchive filestar -czf archive.tar.gz folder/
sshSecure shell connectionssh user@host
scpSecure copyscp file.txt user@host:/path/
historyCommand historyhistory | grep ssh
manManual pagesman ls
echoDisplay messageecho "Hello"
exportSet environment variableexport PATH=$PATH:/new/path