Basic Linux shell commands
ls
Lists the files from present working directory
ls command can accept many arguments. Let us see one by one. These are all not the only commands. I am listing the commands that we have seen during the session.
ls -aβ #lists all files including hidden files
ls -lβ # lists in long list format(including who created, size..)
ls -lh # lists in long list with human readeable format
ls -lSh # lists files based on Size in human readable format
ls -Rβ# recursive list(includes all files inside all directories)
whoami
gives username of the current session
hostname
gives hostname where the current session is
hostnameβ#gives hostname
sudo hostname "new host name"β# changes hostname to new host name
date
gives current date and time
date #gives current date and time
date --date="3 years ago"β#gives same date three years ago
date --date="yesterday"β#gives yesterday's date
cat
concatenate files and print output in the console
cat sample.txtβ#display the content from sample.txt
cat test1.txt test2.txt test3.txt # display all file contents
history
keeps history of all the commands entered so far
history | headβ#gives first 10 commands being used
history | tail #gives last 10 commands being used
#Usually it stores 1k commands in memory
rm
removes file or directories permanently
rm -dβ"filename" # removes empty directories
rm "filename" #removes the file
rm -i "filename"β#prompts user once before delete
rm -r "folder"β#deletes recursively all files inside the folder
rm *.xmlβ#deletes all file with the given extension in the pwd.
man
it is a manual for all shell commands. Through this one can get know details of all commands and its arguments.
man rmβ#gives manual for rm command
man catβ#gives manual for cat command