❌

Reading view

There are new articles available, click to refresh the page.

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

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

❌