­

Linux Basics Every Beginner Should Know

 Linux Basics Every Beginner Should Know

Linux is a powerful operating system that is widely used in servers, development, and even personal computing. Understanding the basic Linux commands is essential to manage files, processes, users, and networks. In this guide, we will cover the essential Linux commands categorized from basic to beginner level.






1. Linux File System Structure

  • / (Root): The top-level directory in Linux.
  • /home: Contains user directories (e.g., /home/user).
  • /etc: System configuration files.
  • /var: Variable data such as logs.
  • /bin: Essential binary files (commands).
  • /usr: Programs, libraries, and system resources.
  • /tmp: Temporary files.

2. Basic Linux Commands

  • pwd: Print the current working directory.

pwd

  • ls: List files and directories.
  • ls

ls -l  # Detailed view

  • cd: Change directory.
  • cd /path/to/directory

cd ~  # Go to the home directory

  • mkdir: Create a new directory.

mkdir Direcotry_Name

  • touch: Create a new empty file.

touch file_name.txt

  • rm: Remove a file or directory.
  • rm file_name.txt

rm -r directory_name  # Remove a directory recursively

  • cp: Copy files or directories.
  • cp source_file destination_file

cp -r source_directory destination_directory  # Copy a directory

  • mv: Move or rename files and directories.
  • mv old_name new_name

mv file_name /new/path/

3. File Permissions

  • ls -l: Display detailed information about files, including permissions.

ls -l

  • chmod: Change file permissions.
  • chmod 755 file_name  # rwx for owner, rx for group and others

chmod +x script.sh   # Give execute permission

  • chown: Change file ownership.

chown user:group file_name

4. File Viewing and Editing

  • cat: View file content.

cat file_name

  • less: View large files interactively.

less file_name

  • nano or vim: Edit files from the terminal.
  • nano file_name

vim file_name

5. System Monitoring and Management

  • top: View running processes and system resource usage.

top

  • ps: Display process status.

ps aux  # List all running processes

  • df: Display disk space usage.

df -h  # Human-readable format

  • du: Display directory and file space usage.

du -sh directory_name

  • free: Display memory usage.

free -h

6. Managing Packages and Software

  • apt (Debian/Ubuntu) or yum (CentOS/RHEL): Install, update, and remove software packages.
  • sudo apt update            # Update package list (Ubuntu/Debian)
  • sudo apt install package_name   # Install software (Ubuntu/Debian)

sudo yum install package_name   # Install software (CentOS/RHEL)

  • dpkg: Manage Debian packages.

sudo dpkg -i package.deb   # Install a .deb package

7. User and Group Management

  • useradd: Add a new user.

sudo useradd username

  • usermod: Modify user details (e.g., change the user’s group).

sudo usermod -aG groupname username

  • passwd: Change user password.

sudo passwd username

  • groupadd: Add a new group.

sudo groupadd groupname

  • id: Display user and group information.

id username

8. Working with Processes

  • kill: Terminate a process.
  • kill process_id

kill -9 process_id  # Force kill

  • bg: Resume a suspended process in the background.

bg

  • fg: Bring a background process to the foreground.

fg

 

Share on Google Plus

About Pawar Live Study

Search Your Query in Search Box.

0 Comments:

Post a Comment

pawarsolution