Basic linux commands

A Free, Stable and Flexible Operating System

Linux is an operating system that is free, open-source and based on Unix. Its stability, security and flexibility make it a popular choice for a wide range of applications, including servers, mobile devices, desktops and more. One of the standout features of Linux is its command line interface (CLI), which provides users with a high level of control over their system and allows for greater customization and automation.

Whether you’re looking for a reliable operating system for your server or a customizable and secure option for your desktop or mobile device, Linux is an excellent choice. With its open-source nature and community-driven development, it is constantly evolving and improving. Discover the benefits of Linux today and see why it’s the preferred choice for so many individuals and organizations around the world.

💡
What is file and what is directory: One of the key differences between files and directories is their purpose. Files are used to store and manage data, while directories are used to organize and manage files. Directories can be nested within other directories, creating a hierarchical structure that allows you to organize your files in a logical and easy-to-access way.

ls: It stands for list and used to display the contents of a directory. When you use ls command, it will show you a list of all the files and directories within the current working directory. You can also give the directory as parameter to ls command to view files of that directory.

ls Desktop/

You can user ls -l to view in long list forma which will include additional informations like permissions, size and modification time. To view hidden files in linux you can use ls -la command.

💡
You can hide files in linux using . before filename. touch .hiddenfile will create a hidden file but when you view it using ls command you won’t see it.

cd : It stands for change directory. means that when you use the cd command, it changes the directory that you are currently working in to a different directory. Here’s an example of how you can change directory from home to Desktop.

cd Documents

If you just use cd it will return you to current user’s home directory. If you want to change directory to Texts directory which is under Desktop. You can simple do this from any directory.

cd ~/Desktop/Texts

In this command, the tilde (~) represents the home directory, which is the directory in which your user account is located. The forward slash (/) is used to separate directory names in the path. The Desktop directory is located inside the home directory, and the Textsdirectory is located inside the Desktopdirectory.

💡
You can view the current working directory using pwd command in linux

cd -command is used to change the current working directory to the previous working directory. This means that it allows you to quickly switch back to the directory you were previously working
in. In above case it will return you to Documents directory.

mkdir : It stands for make directory. Using the mkdircommand with the appropriate directory
name, you can quickly create a new directory in your current working directory or in a specific location.

mkdir Scripts

If you want to create a directory inside Documents directory no matter wherever your current working directory is, then you can use this command.

mkdir /home/Documents/MyDoc

You can also create directory recursively using -p flag. The example below shows how to create directory inside directory.

mkdir -p ~/Videos/sample/2023/wedding

In this command, the -poption is used to create the parent directories if they don’t already exist. The tilde ~represents the home directory of the current user, and the /Videos directory is the directory where the new directory will be created. The sample, 2023, and weddingdirectories are created within the Videosdirectory, with each subsequent directory being created inside the previous one.

Using this command you can quickly directory inside a directory.

Thanks for reading. In the upcoming series i will be discussing about other basic commands like rm , cp , mv, sudo , apt-get , ps , top which will give you a better understanding of linux commands.

Our popular articles:

Basic Server Configuration: https://secnep.com/deploying-a-server-basic-configurations-for-ubuntu/

Ansible setup in servers: https://secnep.com/setup-ansible-in-your-servers/

References:

  1. Linux Commands – SS64 – https://ss64.com/bash/
  1. Linux Man Pages Online – https://man7.org/linux/man-pages/index.html
  1. Linux Command Library – https://linux.die.net/
  1. The Linux Documentation Project – https://tldp.org/
  1. LinuxCommand.org – Learning the shell – http://linuxcommand.org/
Leave a Reply 2

Your email address will not be published. Required fields are marked *


InternationalNews

InternationalNews

Thank you for the auspicious writeup It in fact was a amusement account it Look advanced to more added agreeable from you By the way how could we communicate

tvbrackets

tvbrackets

Simply wish to say your article is as amazing The clearness in your post is just nice and i could assume youre an expert on this subject Well with your permission let me to grab your feed to keep updated with forthcoming post Thanks a million and please carry on the gratifying work