Linux Basic Command Operations.

Linux Basic Command Operations.

lets dvelve into the world of scripting with linux,

Linux powers 90% of supercomputers and 80% of smartphones. It drives cloud infrastructure (AWS, Google Cloud) and web servers. Linux fuels innovation in IoT, automotive, and networking. Secure, reliable, and open-source, Linux dominates tech. Trusted by Google, Amazon, NASA, and millions worldwide.

Accessing Directories

When you first log into a system or open a terminal, the default directory should be your home directory. You can see the exact location by typing echo $HOME.

CommandResult
pwdDisplays the present working directory
cd ~ or cdTakes you to your home directory; Symbol: ~ (tilde)
cd ..Change to parent directory (..)
  1. Cat

Creating a New File - cat > filename creates a new file.

Concatenating Files - cat file1 file2 > outputfile combines the contents of two files into one.

Display File Contents - cat filename displays the contents of a file.

cat > newfile.txt  #txt file is created
cat newfile.txt  #display contents inside the newfile.
cat file1 file2 > file3  #concatenates data from file,file2 and appends it to file3.
  1. echo

echo is like a print statement whatever you give after the echo command it will print it.

echo "Welcome to basics of linux" #It will print the line Welcome to basics of linux
  1. ls

ls - command is used to list all the files,directories(folders) in the current directory you present.

ls #it will lists all the files and folders(directories) in your current location.
ls -l       # List in long format (detailed view)
ls -a       # List all files, including hidden files
  1. touch

touch command is used to create empty files, we can create mutliple files at a time.

touch file1 file2 file3 file4  #we can create 4 files at a time.
  1. mkdir

when we use mkdir it will create a directory(folder) we can create multiple directories too.

mkdir linux  #it will create new directory(folder) named linux.
  1. rmdir

if you want to remove them when not used or to save space use “rmdir <nameofdirectory> it will delete the directory.

rmdir linux #it will remove the directory named linux.
  1. Head

head - used to show the first few lines of a file.

cat file1 | head -n 10 # opens the file1 and displays only first 10 lines from top.
  1. tail

tail - used to show the last few lines of a file.

cat file1 | tail -n 10 # opens the file1 and displays only first 10 lines from bottom.
  1. man

man - used to view documentation.

  • if we forgot how to use any command “man <command name> will help us.”
man cat #will give you documentation on how to use cat command.
  1. exit

when exit command is typed in terminal, it will exit the terminal by leaving the process running.

exit #exits the terminal.
  1. Rebooting and Shutting Down

  • halt and poweroff commands issue shutdown -h to halt the system.

  • reboot issues shutdown -r and causes the machine to reboot instead of just shutting down.

  • if u want to cancel shutdown use shutdown -c.

$ sudo shutdown -h 10:00 "Shutting down for scheduled maintenance."

These are the basic linux commands which are used daily by all the software developers all over the world these are fundamentals on your hands.

Make your hands dirty by practising this commands it is going to be useful and manage the system efficiently.

"HAPPY LEARNING - HAPPY SCRIPTING"

More Commands in next blog till then Cyaaaaaa, Have a good day :)

Quote Of The Day~~

If you can't fly, then run; if you can't run, then walk; if you can't walk, then crawl, but whatever you do, you have to keep moving forward.”

Did you find this article valuable?

Support Sohail's Blog by becoming a sponsor. Any amount is appreciated!