Basic Linux Commands
Task: What is the linux command to
To view what's written in a file.
bhi@ubandupc:~/Desktop/Day3$ echo "My Day3 DevOps Journey is under process" >file.txt
abhi@ubandupc:~/Desktop/Day3$ cat file.txt
My Day3 DevOps Journey is under process
To change the access permissions of files.
abhi@ubandupc:~/Desktop/Day3$ ls -l file.txt
-rw-rw-r-- 1 abhi abhi 40 Mar 20 14:40 file.txt
abhi@ubandupc:~/Desktop/Day3$ chmod 777 file.txt
abhi@ubandupc:~/Desktop/Day3$ ls -l file.txt
-rwxrwxrwx 1 abhi abhi 40 Mar 20 14:40 file.txt
To check which commands you have run till now.
abhi@ubandupc:~/Desktop/Day3$ history
1 lsblk
2 ls /
3 su
4 su root
5 man sudo_root
To remove a directory/ Folder.
abhi@ubandupc:~/Desktop/Day3$ mkdir text
abhi@ubandupc:~/Desktop/Day3$ ls
file.txt text
abhi@ubandupc:~/Desktop/Day3$ rm -rf text/
abhi@ubandupc:~/Desktop/Day3$ ls
file.txt
To create a fruits.txt file and to view the content.
vim fruits.txt
cat fruits.txt
abhi@ubandupc:~/Desktop/Day3$ vim fruits.txt abhi@ubandupc:~/Desktop/Day3$ cat fruits.txt Apple Banana Mango Grapes
- Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
vim devops.txt
To Show only top three fruits from the file.
abhi@ubandupc:~/Desktop/Day3$ head -3 devops.txt
Apple
Mango
Banana
To Show only bottom three fruits from the file.
abhi@ubandupc:~/Desktop/Day3$ tail -3 devops.txt
Kiwi
Orange
Guava.
To create another file Colors.txt and to view the content.
abhi@ubandupc:~/Desktop/Day3$ echo "Yelow , Red , Blue" > Colors.txt
abhi@ubandupc:~/Desktop/Day3$ cat Colors.txt
Yelow , Red , Blue
Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.
abhi@ubandupc:~/Desktop/Day3$ vim Colors.txt
To find the difference between fruits.txt and Colors.txt file.
abhi@ubandupc:~/Desktop/Day3$ diff Colors.txt fruits.txt
1,8c1,4
< Red,
< Pink
< White
< Black
< Blue
< Orange
< Purple
< Grey.
---
> Apple
> Banana
> Mango
> Grapes