DAY-2: Linux: Basics Commands
Today marks Day 2 of our 90-day DevOps journey
Introduction🎉
Linus Torvalds developed Linux in 1991, and nine out of ten software engineers still choose Linux over any other OS. (No offense; please don’t throw me out of the Windows.) Engineers recommended Linux as it has some magical features that make it easy to play and use. Who doesn’t like penguins and wants to play in the tree house? Yes, a tree house. Linux has a rooted, inverted tree-like structure where / is the root directory. So, it is just like playing in the treehouse. In the context of a tree house, you could refer to the root directory () of Linux as the "Trunk Directory." This term aligns with the metaphor of a tree house, where the trunk represents the main central structure that supports and connects all the other parts.
Advantages of Linux 🐱🏍
Let’s talk about the advantages of Linux:
Open source
Have a supportive user & developer community.
It has robust security features.
No need for any anti-virus.
Low resource usage and optimized performance.
Easily customization that’s makes it suitable for use development purposes.
Suitable for both small devices and large servers.
Flavours of Linux 🍨
Just as assorted flavors of ice cream offer unique tastes and ingredients. The term "flavors" helps to convey the idea that each Linux distribution has its distinct blend of features, software choices, package selections, default configurations, user experiences, and philosophies, such as:
Cent OS
RHEL (Red Hat Enterprise Linux)
Ubuntu
Fedora
Kali Linux
Gentoo
Linux Mint
Slackware
Time to get some hands-on Linux now.
Basic Commands ✍
#To list all the contents of directory ls #To print the text echo "text you want to print" #To change directory cd #To print the directory, you are currently in pwd #To create a new directory – mkdir < new-directory> #To use multiple commands together, done by separating each command with semicolon. cd new_dir; mkdir blues; pwd #To remove a directory, rm -r <mkdir-name> #To move file from one directory to another mv /path/to/source/file /path/to/destination/directory/ #To copy directory from one location to another cp -r /path/to/source/directory /path/to/destination/directory #To create a new file with no contents touch new_file.txt #Add contents to the file. cat > new_file.txt #To exit and save the file use CTRL + D #In case you feel like Sanjay Singhania you can simply go for whoami #command and get your memory back.
Task 🎯
Theory can take a break; action is authentic! Let’s move to the day-2 task.
Questions
Solutions
#1. To check present working directory: pwd #2. 2.List all the files or directories including hidden files: ls -a #or ls -la #3. 3.To create a nested directory A/B/C/D/E mkdir -p A/B/C/D/E
Points To Remember💭
-p
: The "parents" option creates parent directories if they don't exist, ensuring all directories in the specified path are created, even with missing intermediate directories.ls -la
: This command lists all files and directories, including hidden files, providing a detailed output in a long format. It includes file permissions, owner, group, size, modified timestamp, and names of files and directories.ls -a
: This command lists all files and directories, including hidden files, displaying only the names. Hidden files start with a dot (e.g., ".file.txt" or ".hidden_directory").