Skip to main content

Command Palette

Search for a command to run...

Basic Linux Commands: A Beginner's Journey

A Newcomer's Guide to Efficient System Navigation a Linux system.

Published
β€’3 min read
Basic Linux Commands: A Beginner's Journey

Linux commands are the backbone of managing and navigating a Linux-based system. To manage and navigate a Linux-based system, utilise Linux commands. As I have ventured into the realm of Linux, I have learned some basic commands that every newcomer must know. Here is how I mastered some of these basic Linux commands.

πŸ“‚ Listing Commands

1. Checking Your Present Working Directory

To know your current directory in the filesystem, use: pwd command.

2. Listing Files and Directories

To list all files and directories, use: ls command.

To list all files and directories, including hidden ones, use: ls -a command.

πŸ“‚ Directory Management Commands

Create a Directory (Folder)

To create directory in linux system, use: mkdir <directiry_name> command.

Creating Nested Directories

Creating nested directories can be done in one go by using: mkdir -p A/B/C/D/E command. here -p stands for "parents" It means that mkdir will create any necessary parent directories that don't already exist.

Creating multiple directories

To create multiple directories in one go by using brace expresion. use: mkdir dir_name{1..5}

with the command mkdir dir{1..5}, a total of five directories will be created. They will be named dir1, dir2, dir3, dir4, and dir5.

Removing a Directory

To remove a directory and its contents, use: rm -r directory_name

πŸ“„ Create, Viewing and Editing Files

Creating the File

To create a new file, use: touch filename

Inserting Data in the File

To insert data into a file while creating it, use: echo "Your text here" > filename.txt

Viewing File Contents

To view the contents of a file, use: cat filename

Changing File Permissions

To change the access permissions of a file, use: chmod permissions filename

Permission Format

Permissions can be set using symbolic or numeric modes.

Symbolic Mode

  • Read (r): Permission to read the file.

  • Write (w): Permission to modify the file.

  • Execute (x): Permission to execute the file.

Symbolic permissions are specified for three different classes of users:

  • User (u): The owner of the file.

  • Group (g): Users who are members of the file’s group.

  • Others (o): All other users.

Example: chmod u+rwx,g+rx,o+r filename

This command sets the user to have read, write, and execute permissions, the group to have read and execute permissions, and others to have read permission.

πŸ“„ File Creation and Manipulation

Creating and Viewing a File

To create a new file and then view its content:

touch fruits.txt
cat fruits.txt

Adding Content to a File

To add multiple lines of content to a file:

echo -e "Apple\nMango\nBanana\nCherry\nKiwi\nOrange\nGuava" > fruits.txt

Showing Top Three Lines

To display the top three lines of a file:

Showing Bottom Three Lines

To display the bottom three lines of a file:

tail -n 3 fruits.txt

Creating Another File and Adding Content

To create another file and add content:

touch Colors.txt
echo -e "Red\nPink\nWhite\nBlack\nBlue\nOrange\nPurple\nGrey" > Colors.txt

Finding Differences Between Two Files

To find the differences between two files:

diff fruits.txt Colors.txt

πŸ”„ Command History

Checking Command History

To see the list of commands you’ve run so far, use history command.

Conclusion

Learning these basic Linux commands has been a rewarding experience. They form the foundation for managing files, directories, and permissions effectively. Whether you are a beginner or looking to refresh your knowledge, mastering these commands is essential for navigating and managing a Linux environment efficiently.

More from this blog

Untitled Publication

13 posts