Linux powers the modern computing landscape, and in this I explore Linux and its basic commands.
Commands | What it does |
Linux | Operating System - Open source, multiuser&multiprocessing, security |
Ubuntu | Distibution of linux Other distributions: centOS, Amazon linux, RHEL |
Shell | Terminal -lets user executes command -communicates with kernal |
kernal | Heart of Linux - connect shell to Hardware |
$ Whoami | To see the currently logged-in user |
$ touch filename.txt | Create a file |
$ nano filename.txt | open the nano editor |
$ vi filename.txt | open the vi editor |
$ vim filename.txt | open the vim editor |
$ ls | list the files in a current directory |
$ls -l | list the file with long details |
$ls -a | list all hidden files (files which start with .<filename> are hidden files ) |
$ls -i | list the files with index no nodes |
$ls .sh | list all the files with .sh extension |
$ls -al | list all hidden files with details |
$ls -d / | list only directories |
$ cat <filename> | To display the contents of the file |
$ pwd | Present working Directory |
$ cd . | Current directory |
$ cd .. | Previous directory |
$ cd - | Go to the last working directory |
$ cd | Go to the home directory |
$ echo "Hello" | To print |
$ rm filename.txt | To delete file |
$ mkdir LinuxForDevops | To create folder |
$ rmdir LinuxForDevops | To delete folder |
$ mkdir -p Linux/Shell | To create multiple nested folders |
$ cp names.txt Folder1/ | To copy names.txt file in Folder Folder1 |
$ mv devops.txt cloud.txt | To rename a file |
$ mv cloud.txt ../gcpcloud.txt | To rename and also move to previous directory |
$ find . | To find in current directory |
$ find . -type d | To find only directories |
$ find . -type f | To find only files in current directory |
$ find . -type f -mmin +2 | To find files in current directory which modified in more than 2 min |
$ find . -type f -mtime -2 | To find files accessed in last 2 days |
$ find -name "*.txt" | To find all files with .txt |
$ find . -empty | To find empty files |
GREP Command | Global Regular Expression Print -To search text in file or system |
$grep "Ansible" names.txt | To find text "Ansible" in names.txt file |
$ grep -i "Network" | Not case sensitive |
$ grep -w "Network" | To find complete "Network" in names.txt file |
$ df | Displays the amount of disk space available on the filesystem |
$ du | Measures the disk space occupied by files or directories. |
$ free | Outputs a summary of RAM usage |
$ vmstat | Gives the information about processes, memory, paging, block IO, disk, and CPU scheduling |
To obtain domain name or IP address mapping | |
$ ifconfig | To assign an address to a network interface and to configure or display the current network interface configuration information |
Sharing screenshots of few commands :
Day 3 Task
To view what's written in a file.
To change the access permissions of files.
To check which commands you have run till now.
To remove a directory/ Folder.
To create a fruits.txt file and to view the content.
Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
To Show only top three fruits from the file.
To Show only bottom three fruits from the file.
To create another file Colors.txt and to view the content.
Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.
To find the difference between fruits.txt and Colors.txt file.
Happy Learning!