Basic Linux Commands

Basic Linux Commands

·

2 min read

Task 2 of #90daysofdevops challenge

What is Linux?

Linux is an operating system, which is based on Linux Kernel. It is an open-source operating system where it can run on different hardware platforms. It provides a free and low-cost operating system for users. It is a user-friendly environment where they can easily modify and create variations in the source code.

Basic Commands

/ is your root directory 
~ is your home directory
uname     : it show name of kernel (OS)
uname -r  : it show version of kernel 
clear     : it use for clear screen
whoami    : it show currently login user name
history   : it show list of previously used commands
date      : it show time and date
cal       : show this month's calendar
users     : Display the username of all users currently logged on the system
lastlog  : The lastlog command is used to find the details of a recent         login of all users
Tail     : This command prints the last N number of data of the given input. By default, it prints 10 lines. 
Chmod    : This command is used to change the access permissions of files and directories.
Chown    : This command is used to change the file Owner or group.

Listing commands

ls option_flag arguments --> list the sub-directories and files available in the present directory.

ls -l  :- list the files and directories in a long list format with extra information

ls -a  :- list all including hidden files and directory

ls *.sh :- list all the files having .sh extension.

ls -i :- list the files and directories with index numbers inodes.

ls -d */ :- list only directories.(we can also specify a pattern)

Directory commands

pwd --> print work directory. Gives the present working directory.

cd path_to_directory --> change the directory to the provided path

cd ~ or just cd --> change the directory to the home directory

cd - --> Go to the last working directory.

cd .. --> change the directory to one step back.

cd ../.. --> Change directory to 2 levels back.

mkdir directoryName --> to make a directory in a specific location
Examples:
mkdir newFolder              : make a new folder 'newFolder'
mkdir .NewFolder             : make a hidden directory (also . before a file          to make it hidden)
mkdir A B C D                : make multiple directories at the same time
mkdir /home/user/Mydirectory : make a new folder in a specific location
mkdir -p  A/B/C/D            : make a nested directory

Thanks For Reading! :)