Day 2 - Basic linux commands
📚 Introduction to Linux
💡Free and open-source operating system.
💡 Provides a powerful and flexible platform for computing.
💡 Developed by Linus Torvalds in 1991.
💡 Offers various distributions like Ubuntu, Fedora, and Debian.
💡 Known for stability, security, and scalability.
💡 Empowers users with customization options and extensive software libraries.
💡 Provides both a command-line interface and a graphical user interface.
💡 Widely adopted across devices and industries.
💡 Suitable for individuals, businesses, and organizations seeking a robust computing environment.
📚Linux Architecture
The components of the Linux Operating System include Applications, Shell, Kernel, and Hardware.
Hardware: Physical parts of computers like such as CPU, monitor, keyboard, hard disk, and other connected devices to CPU.
Kernel: It is considered as the core part of Linux and is generally responsible for all major activities of OS such as process management, device management etc
Shell: It is an environment in which we run our program, command and shell scripts. It is an interface between the user and the Kernel that hide all complexities of functions of the kernel from the user. It is used to execute commands. Common shell programs in Unix-like systems include Bash (Bourne Again SHell) and Zsh (Z Shell), while Windows systems typically use the Command Prompt or PowerShell.
📚Basic Commands in Linux
💡Listing commands
ls option_flag arguments
--> List the subdirectories and files available in the present directory
Examples:
ls -l
- List the files and directories in long list format with extra informationls -a
- List all including hidden files and directoryls *.sh
- list all the files having .sh extension.ls -i
- List the files and directories with index numbers Inodesls -d */
- list only directories.(we can also specify a pattern)
💡Directoy commands
pwd
--> print work directory. Gives the present working directory.cd path_to_directory
--> Change the directory to the provided pathcd ~
or justcd
--> change directory to the home directorycd -
--> Go to the last working directory.cd ..
--> change directory to one step back.cd ../..
--> Change directory to 2 levels back.mkdir directoryName
--> to make a directory in a specific location
💡File Operations 📄
touch
: Create an empty file.touch filename.txt
cp
: Copy files or directories.
cp file.txt /path/to/destination/mv
: Move or rename files or directoriesmv file.txt /path/to/destination/
rm
: Remove files or directories.rm -r directory/ --> Remove a directory and its contents
Let's begin by performing a few tasks that will immediately cover a few commands.
TASK 1: Check your present working directory
ubuntu@ip-172-31-90-1:~/shanu$ pwd
/home/ubuntu/shanu
TASK 2: List all the files or directories including hidden files.
ubuntu@ip-172-31-90-1:~/shanu$ ls -la
total 8
drwxrwxr-x 2 ubuntu ubuntu 4096 Jul 19 15:13 .
drwxr-x--- 5 ubuntu ubuntu 4096 Jul 19 14:57 ..
-rw-rw-r-- 1 ubuntu ubuntu 0 Jul 19 15:03 test-1.txt
-rw-rw-r-- 1 ubuntu ubuntu 0 Jul 19 15:03 test-2.txt
-rw-rw-r-- 1 ubuntu ubuntu 0 Jul 19 15:03 test-3.txt
-rw-rw-r-- 1 ubuntu ubuntu 0 Jul 19 15:03 test-4.txt
-rw-rw-r-- 1 ubuntu ubuntu 0 Jul 19 15:03 test-5.txt
-rw-rw-r-- 1 ubuntu ubuntu 0 Jul 19 15:03 test-6.txt
TASK 3 : Create a nested directory A/B/C/D/E
ubuntu@ip-172-31-90-1:~/shanu$ mkdir -p A/B/C/D/E
ubuntu@ip-172-31-90-1:~/shanu$ cd A/B/C/D/
ubuntu@ip-172-31-90-1:~/shanu/A/B/C/D$ pwd
/home/ubuntu/shanu/A/B/C/D
🎉Conclusion
I hope this article helped you to learn the basics of Linux commands. Thank you for taking the time to read!🙏 Drop me your feedback/comments. Feel free to share this article with others if you like it.
Subscribe to my newsletter
Read articles from Shahanaz Shanu directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by