Basic Linux Commands: A Quick Guide for Beginners
Table of contents
Linux provides a wide array of commands that allow users to navigate the system, manage files, and interact with directories efficiently. In this post, we will explore listing commands and directory commands that are frequently used, with explanations and practical examples.
Listing Commands
Listing commands help you view files and directories in the current working directory. By using various options and flags, you can customize how information is displayed.
- ls option_flag arguments
Used to list the subdirectories and files available in the current directory.
Examples:
ls -l
Lists the files and directories in long format with extra information, such as permissions, owner, and size.ls -l
ls -a
Lists all files, including hidden files and directories.ls -a
ls \.sh Lists all files with the*
.sh
extension.ls *.sh
ls -i
Lists files and directories with their inode numbers.ls -i
ls -d\ / Lists only directories in the current directory (you can also specify a pattern).*
ls -d */
Directory Commands
Managing directories efficiently is key to mastering Linux. Below are some essential commands that help you navigate and manage directories:
pwd
Prints the current working directory.pwd
cd path_to_directory
Changes the current directory to the specified path.cd /home/user/Documents
cd
Changes the directory to the home directory.cd
cd -
Returns to the last working directory.cd -
cd ..
Moves up one directory level.cd ..
cd ../..
Moves up two levels in the directory tree.cd ../..
mkdir directoryName
Creates a directory in a specified location.
Examples:
mkdir newFolder
Creates a new folder namednewFolder
.mkdir newFolder
mkdir .NewFolder
Creates a hidden folder (adding.
before the folder name makes it hidden).mkdir .NewFolder
mkdir A B C D
Creates multiple directories (A
,B
,C
,D
) at the same time.mkdir A B C D
mkdir /home/user/MyDirectory
Creates a new folder in a specific location.mkdir /home/user/MyDirectory
mkdir -p A/B/C/D
Creates nested directories in one command.mkdir -p A/B/C/D
Conclusion
Mastering these basic Linux commands can enhance your ability to navigate and manage files in your Linux environment.
Subscribe to my newsletter
Read articles from sravani punreddy directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by