Getting Started with Linux: Essential Commands for Beginners
Linux is a powerful and versatile operating system, loved by developers, system administrators, and tech enthusiasts alike. It's open-source, highly customizable, and perfect for those who enjoy understanding how their system works at a deeper level. If you’re new to Linux, learning some basic commands will help you navigate the system more effectively. This blog will introduce you to some essential Linux commands and how to use them.
1. Navigating the File System
Just like any other operating system, Linux has a file system that organizes files and directories. Here are a few basic commands to get around:
pwd
: Print Working Directory
This command displays the current directory you’re in.$ pwd /home/nischal
ls
: List Files
This command lists all the files and directories in the current directory.$ ls Documents Downloads Pictures Music
cd
: Change Directory
Usecd
to move to another directory. For example, to move to theDocuments
directory:$ cd Documents
You can use
cd ..
to move back one directory.
2. Managing Files and Directories
Linux allows you to easily create, delete, and move files and directories. Here are some basic file manipulation commands:
mkdir
: Make Directory
Create a new directory withmkdir
.$ mkdir my_new_directory
touch
: Create a New File
Create an empty file using thetouch
command.$ touch newfile.txt
rm
: Remove Files or Directories
Userm
to delete files or directories. Be careful when using this, as it deletes files permanently!$ rm oldfile.txt
For directories, use the
-r
option to delete recursively:$ rm -r my_directory
cp
: Copy Files or Directories
To copy files, usecp
. To copy a directory and its contents, use the-r
option.$ cp file.txt /home/nischal/Documents $ cp -r folder_name /home/nischal/Backup
mv
: Move or Rename Files
Usemv
to move or rename files and directories.$ mv file.txt /home/nischal/Documents # Move file $ mv oldname.txt newname.txt # Rename file
3. Viewing and Editing Files
Linux provides several ways to view and edit files directly from the terminal:
cat
: Concatenate and Display Files
Usecat
to display the contents of a file.$ cat file.txt
nano
: Text Editor
nano
is a simple text editor you can use in the terminal to edit files.$ nano file.txt
less
: View Files
Useless
to view long files page by page.$ less largefile.txt
4. System Monitoring and Information
Linux also gives you the ability to monitor system resources and check system information with ease:
top
: Task Manager
Thetop
command displays a real-time view of system processes, including CPU and memory usage.$ top
df
: Disk Space Usage
df
shows you the amount of disk space used on your system.$ df -h
du
: Disk Usage
Usedu
to check the size of a specific directory or file.$ du -sh /home/nischal/Documents
uname
: System Information
uname
shows system information, such as the kernel version.$ uname -a
5. Package Management
Linux systems use package managers to install, update, and remove software. Depending on the distribution you are using, you will use different commands:
apt
(for Ubuntu/Debian systems):
Useapt
to install new software.$ sudo apt update # Update the package list $ sudo apt install vim # Install a new program (e.g., vim)
yum
(for CentOS/RHEL systems):
Similar toapt
, but used in Red Hat-based systems.$ sudo yum install vim
6. Working with Permissions
Linux is known for its robust security, and part of that is file permissions. Each file and directory has permissions that control who can read, write, and execute it.
chmod
: Change File Permissions
Usechmod
to modify file or directory permissions.$ chmod +x script.sh # Give execute permission
chown
: Change Ownership
Usechown
to change the owner of a file.$ sudo chown nischal file.txt
Final Thoughts
Learning Linux commands can seem daunting at first, but with practice, you'll get the hang of it quickly. These basic commands will help you navigate, manage files, and get to know your Linux system better. There’s so much more you can do with Linux, from advanced scripting to system administration, but mastering the basics is the first step toward becoming a Linux power user!
Subscribe to my newsletter
Read articles from Nischal Baidar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by