SurferCloud Blog SurferCloud Blog
  • HOME
  • NEWS
    • Latest Events
    • Product Updates
    • Service announcement
  • TUTORIAL
  • COMPARISONS
  • INDUSTRY INFORMATION
  • Telegram Group
SurferCloud Blog SurferCloud Blog
SurferCloud Blog SurferCloud Blog
  • HOME
  • NEWS
    • Latest Events
    • Product Updates
    • Service announcement
  • TUTORIAL
  • COMPARISONS
  • INDUSTRY INFORMATION
  • Telegram Group
  • banner shape
  • banner shape
  • banner shape
  • banner shape
  • plus icon
  • plus icon

Essential Linux Commands for Beginners

December 13, 2024
5 minutes
INDUSTRY INFORMATION,TUTORIAL
189 Views

Linux is a powerful and widely used operating system, especially in server environments. Mastering basic Linux commands is essential for system administrators, developers, and anyone working with Linux servers. This guide introduces you to the most important Linux commands, explains what they do, and provides simple usage examples.


1. Navigating the File System

pwd - Print Working Directory

The pwd command shows the current directory you are working in.

Example:

pwd

Output:

/home/user

This indicates that you are in the /home/user directory.

ls - List Files and Directories

The ls command lists all files and directories in your current location.

Example:

ls

You can also use options like -l for detailed output and -a to show hidden files:

ls -la

2. File Management Commands

cd - Change Directory

The cd command allows you to move between directories.

Example:

cd /home/user/Documents

To return to the previous directory, use:

cd ..

To go to your home directory:

cd ~

touch - Create New Files

The touch command creates an empty file.

Example:

touch newfile.txt

This will create an empty file called newfile.txt in the current directory.

cp - Copy Files and Directories

The cp command copies files from one location to another.

Example:

cp file1.txt /home/user/Documents/

This copies file1.txt to the /home/user/Documents/ directory.

mv - Move or Rename Files

The mv command moves or renames files.

Example (Move):

mv file1.txt /home/user/Documents/

Example (Rename):

mv oldname.txt newname.txt

rm - Remove Files and Directories

The rm command deletes files or directories.

Example (Delete a File):

rm file1.txt

Example (Delete a Directory):

rm -r /home/user/old_folder

⚠️ Be cautious when using rm, as it permanently deletes files.


3. Viewing and Editing Files

cat - View File Content

The cat command displays the contents of a file.

Example:

cat file1.txt

To view large files, use less or more for better navigation.

nano and vim - Edit Text Files

  • nano: A beginner-friendly text editor.
  • vim: A more advanced editor with powerful features.

Example (Edit file with nano):

nano file1.txt

After editing, press Ctrl + O to save and Ctrl + X to exit.

Example (Edit file with vim):

vim file1.txt

To enter edit mode, press i. To save and exit, press Esc, type :wq, and press Enter.


4. Permissions and Ownership

chmod - Change File Permissions

The chmod command changes file permissions.

Example (Make a File Executable):

chmod +x script.sh

Example (Set Permissions Using Numbers):

chmod 755 file1.txt

Here, 755 represents read, write, and execute permissions for the file owner, and read and execute permissions for others.

chown - Change File Ownership

The chown command changes the owner of a file.

Example:

chown user:group file1.txt

This sets user as the file owner and group as the group owner.


5. System Monitoring Commands

top - View Running Processes

The top command shows system processes, CPU usage, and memory usage.

Example:

top

To exit, press q.

ps - View Active Processes

The ps command shows currently running processes for the current user.

Example:

ps aux

This shows a detailed list of all running processes.

df - Disk Space Usage

The df command displays available disk space.

Example:

df -h

The -h option shows human-readable file sizes (KB, MB, GB).

du - Disk Usage of Files and Directories

The du command shows the disk space used by specific files and directories.

Example:

du -sh /home/user/Documents

This displays the total size of the /home/user/Documents directory.


6. Networking Commands

ping - Test Network Connectivity

The ping command checks if a host is reachable.

Example:

ping google.com

This sends ICMP packets to Google's server and reports the response time.

ifconfig or ip - View Network Interfaces

The ifconfig or ip command shows network interface information.

Example (Ifconfig):

ifconfig

Example (IP command):

ip a

netstat - View Network Connections

The netstat command shows active network connections.

Example:

netstat -tuln

This shows TCP and UDP connections and the ports they are using.


7. User Management

whoami - Display Current User

The whoami command shows the name of the currently logged-in user.

Example:

whoami

adduser and useradd - Create New Users

The adduser and useradd commands create new users.

Example (adduser):

adduser newuser

Example (useradd):

useradd newuser

passwd - Change Password

The passwd command changes a user's password.

Example:

passwd newuser

8. Package Management Commands

apt-get - Install, Update, and Remove Packages

For Debian/Ubuntu systems, apt-get is used to manage packages.

Update Package Lists:

sudo apt-get update

Upgrade Installed Packages:

sudo apt-get upgrade

Install New Package:

sudo apt-get install package_name

Remove Package:

sudo apt-get remove package_name

9. System Shutdown and Restart

shutdown - Shut Down the System

To shut down the system immediately:

sudo shutdown now

To schedule a shutdown after 10 minutes:

sudo shutdown +10

reboot - Restart the System

To reboot the system:

sudo reboot

10. File Compression Commands

tar - Archive Files

The tar command creates and extracts archives.

Create a .tar.gz Archive:

tar -czvf archive.tar.gz /path/to/files

Extract a .tar.gz Archive:

tar -xzvf archive.tar.gz

zip and unzip - Compress and Extract ZIP Files

Create a ZIP File:

zip archive.zip file1.txt file2.txt

Extract a ZIP File:

unzip archive.zip

Take Your Linux Skills to the Next Level with SurferCloud

If you want a powerful Linux server to practice and master these commands, consider SurferCloud. SurferCloud offers Linux VPS with high performance, stable uptime, and global data centers. Whether you're a developer, student, or system administrator, SurferCloud's VPS can help you build and manage your projects efficiently.

Tags : basic Linux commands best Linux VPS essential Linux commands Linux beginner commands Linux terminal commands Linux VPS commands SurferCloud Linux VPS

Related Post

3 minutes INDUSTRY INFORMATION

Amazon VPS Pricing: Comprehensive Insights fo

Amazon Web Services (AWS) is a global leader in cloud c...

5 minutes INDUSTRY INFORMATION

9 Best Cloud Server Hosting Providers for 202

As we head into 2024, cloud server hosting remains a co...

3 minutes INDUSTRY INFORMATION

Understanding MLC SSD: A Balanced Choice for

As data storage technology advances, SSDs (Solid-State ...

Affordable CDN

ucdn

2025 Special Offers:

annual vps

Light Server promotion:

ulhost-promo

Cloud Server promotion:

cloud server

Copyright © 2024 SurferCloud All Rights Reserved.  Sitemap.