🔹Linux Basic Commands
Hii I am a backend/DevOps engineer.I have a experience with development and automation.I mostly work with Python, django, Cloud based technologies.
refer:- https://gopalgtm.hashnode.dev/what-is-linux
Day 3 Task: Basic Linux Commands
Task: What is the linux command to
To view what's written in a file.
cat file_name
To change the access permissions of files.
To change the access permissions of files in Linux, you can use the
chmodcommand. Access permissions determine the level of access and control that different users or groups have over a file. The permissions are represented by three sets of three characters: User, Group, and Other.Each set consists of three permission types:
r(read): Allows reading or viewing the file.w(write): Allows modifying or editing the file.x(execute): Allows executing or running the file if it is a script or program.
Here's how the permissions are represented and what they mean:
rwx: Indicates full permissions (read, write, and execute).-: Indicates that a specific permission is not granted.
The numbers 0-7 are used to represent different permission combinations. Each permission type has an associated number value:
r(read) = 4w(write) = 2x(execute) = 1
To set permissions, you can assign the appropriate number value to each permission type and sum them up. Here are some examples:
777means full permissions for all users (read, write, and execute).755means the owner has full permissions, while the group and others have read and execute permissions.644means the owner has read and write permissions, while the group and others have only read permissions.
To apply permissions using the chmod command, you need to specify the permission set followed by the file or directory you want to modify. Here are a few examples:
Grant full permissions (read, write, and execute) to all users:
chmod permissions filename
chmod 777 myfile.txt

To check which commands you have run till now.
history
To remove a directory/ Folder.
rm -r myfolderTo create a fruits.txt file and to view the content.
rm fruits.txtAdd content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
echo -e "Apple\nMango\nBanana\nCherry\nKiwi\nOrange\nGuava" >> devops.txt
To Show only top three fruits from the file.
head -n 3 fruits.txtTo Show only bottom three fruits from the file.
tail -n 3 fruits.txtTo create another file Colors.txt and to view the content.
touch Colors.txt cat Colors.txtAdd content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.
echo -e "Red\nPink\nWhite\nBlack\nBlue\nOrange\nPurple\nGrey" >> Colors.txt cat Colors.txtTo find the difference between fruits.txt and Colors.txt file.
diff fruits.txt Colors.txt



