Slider

Top 20 Linux Commands Every Ubuntu User Must Know

Ubuntu is one of the most popular Linux distributions, known for its user-friendly interface and robust functionality. However, to truly harness the power of Ubuntu, it’s essential to learn the Linux command line. Here’s a guide to the top 20 Linux commands every Ubuntu user should know, whether you’re a beginner or an experienced user.


1. ls – List Directory Contents

The ls command lists the files and directories in the current directory.

  • Usage:

    ls
    ls -l
    ls -a
  • Common Options:

    • -l: Long format listing with details like file size and permissions.

    • -a: Show hidden files.


2. cd – Change Directory

The cd command lets you navigate between directories.

  • Usage:

    cd /path/to/directory
    cd ..  # Move up one directory
    cd ~   # Go to the home directory

3. pwd – Print Working Directory

Displays the full path of the current directory.

  • Usage:

    pwd

4. touch – Create an Empty File

Creates a new, empty file in the current directory.

  • Usage:

    touch filename.txt

5. mkdir – Make Directory

Creates a new directory.

  • Usage:

    mkdir new_directory
    mkdir -p nested/directory/structure
  • Tip: Use -p to create parent directories as needed.


6. rm – Remove Files or Directories

Deletes files and directories.

  • Usage:

    rm file.txt
    rm -r directory_name  # Delete a directory
  • Warning: Be careful with rm, as deleted files cannot be easily recovered.


7. cp – Copy Files and Directories

Copies files and directories.

  • Usage:

    cp source_file destination_file
    cp -r source_directory destination_directory

8. mv – Move or Rename Files

Moves files or directories and can also rename them.

  • Usage:

    mv old_name.txt new_name.txt
    mv file.txt /new/location/

9. cat – Concatenate and Display File Contents

Displays the contents of a file.

  • Usage:

    cat file.txt

10. nano – Text Editor

Opens the Nano text editor for editing files.

  • Usage:

    nano file.txt

11. sudo – Execute Commands as Superuser

Grants temporary superuser privileges.

  • Usage:

    sudo apt update

12. apt – Package Manager

Manages software installation and updates.

  • Usage:

    sudo apt update       # Update package list
    sudo apt upgrade      # Upgrade all installed packages
    sudo apt install package_name  # Install a package
    sudo apt remove package_name   # Remove a package

13. df – Disk Space Usage

Shows disk space usage for file systems.

  • Usage:

    df -h
  • Tip: Use -h for human-readable sizes.


14. du – Directory Disk Usage

Displays the disk usage of files and directories.

  • Usage:

    du -h
    du -sh directory_name

15. top – Monitor System Processes

Provides a real-time view of running processes and resource usage.

  • Usage:

    top

16. ps – Display Running Processes

Lists running processes.

  • Usage:

    ps aux

17. kill – Terminate Processes

Ends a process by its PID (Process ID).

  • Usage:

    kill PID
    kill -9 PID  # Forcefully terminate a process

18. chmod – Change File Permissions

Modifies file or directory permissions.

  • Usage:

    chmod 755 file.sh
    chmod u+x script.sh  # Make a file executable

19. chown – Change File Ownership

Changes the owner and group of a file or directory.

  • Usage:

    sudo chown user:group file.txt

20. tar – Archive Files

Creates or extracts tarball archives.

  • Usage:

    tar -cvf archive.tar file1 file2
    tar -xvf archive.tar

Conclusion

These 20 commands cover the basics of navigating and managing your Ubuntu system. By mastering these commands, you’ll unlock the full potential of the Linux command line and improve your productivity. Practice regularly to build confidence, and don’t hesitate to explore more advanced commands as you progress.

0

No comments

Post a Comment

© all rights reserved
made with by templateszoo