0% found this document useful (0 votes)
6 views

Basic Linux Commands

li

Uploaded by

kilofo1542
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Basic Linux Commands

li

Uploaded by

kilofo1542
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Sure!

Here are some basic Linux commands that are commonly used:

### File and Directory Management

- **`ls`**: Lists files and directories in the current directory.

- `ls -l`: Lists with detailed information (permissions, owner, size, modification date).

- `ls -a`: Lists all files, including hidden ones (those starting with a dot).

- **`cd`**: Changes the current directory.

- `cd /path/to/directory`: Navigates to the specified directory.

- `cd ..`: Moves up one directory level.

- `cd ~`: Navigates to the home directory.

- **`pwd`**: Prints the current working directory.

- **`mkdir`**: Creates a new directory.

- `mkdir new_directory`: Creates a directory named `new_directory`.

- **`rmdir`**: Removes an empty directory.

- `rmdir directory_name`: Removes the specified empty directory.

- **`rm`**: Removes files or directories.

- `rm file_name`: Removes the specified file.

- `rm -r directory_name`: Removes a directory and its contents recursively.

- `rm -f file_name`: Forces the removal of a file without prompting.

- **`cp`**: Copies files or directories.

- `cp source_file destination_file`: Copies `source_file` to `destination_file`.

- `cp -r source_directory destination_directory`: Copies a directory recursively.


- **`mv`**: Moves or renames files or directories.

- `mv old_name new_name`: Renames `old_name` to `new_name`.

- `mv file_name /path/to/destination`: Moves `file_name` to the specified directory.

### File Viewing and Editing

- **`cat`**: Concatenates and displays the contents of files.

- `cat file_name`: Displays the contents of `file_name`.

- **`less`**: Views file contents interactively, allowing you to scroll.

- `less file_name`: Opens `file_name` for viewing.

- **`head`**: Displays the first few lines of a file.

- `head file_name`: Shows the first 10 lines by default.

- **`tail`**: Displays the last few lines of a file.

- `tail file_name`: Shows the last 10 lines by default.

- `tail -f file_name`: Follows the file and displays new lines as they are added (useful for logs).

- **`nano`**, **`vim`**, **`vi`**: Text editors for editing files.

- `nano file_name`: Opens `file_name` in the nano editor.

- `vim file_name` or `vi file_name`: Opens `file_name` in the vim or vi editor.

### System Information

- **`df`**: Displays disk space usage.

- `df -h`: Shows disk usage in a human-readable format (e.g., GB, MB).
- **`du`**: Displays disk usage of files and directories.

- `du -h`: Shows disk usage in a human-readable format.

- **`top`**: Displays real-time system processes and resource usage.

- **`ps`**: Displays information about active processes.

- `ps aux`: Shows detailed information about all processes.

- **`uname`**: Displays system information.

- `uname -a`: Shows all available system information (kernel version, machine type, etc.).

- **`free`**: Displays memory usage.

- `free -h`: Shows memory usage in a human-readable format.

### File Permissions and Ownership

- **`chmod`**: Changes file permissions.

- `chmod 755 file_name`: Sets the file permissions to `rwxr-xr-x`.

- **`chown`**: Changes file ownership.

- `chown user:group file_name`: Changes the owner and group of `file_name`.

### Networking

- **`ping`**: Tests connectivity to a host.

- `ping hostname_or_ip`: Sends ICMP echo requests to the specified host.

- **`ifconfig`** or **`ip`**: Displays network interface configuration.


- `ifconfig`: Shows network interface details (older command, may be deprecated in some
distributions).

- `ip addr`: Shows network interface details (newer command).

- **`netstat`**: Displays network connections, routing tables, interface statistics.

- `netstat -tuln`: Shows listening ports and their associated services.

### Package Management (for Debian-based systems like Ubuntu)

- **`apt-get`**: Manages packages.

- `sudo apt-get update`: Updates the list of available packages.

- `sudo apt-get upgrade`: Upgrades installed packages.

- `sudo apt-get install package_name`: Installs a new package.

- `sudo apt-get remove package_name`: Removes a package.

### Others

- **`man`**: Displays the manual page for a command.

- `man command_name`: Shows the manual for `command_name`.

- **`grep`**: Searches for text in files.

- `grep "search_term" file_name`: Searches for `search_term` in `file_name`.

- **`find`**: Searches for files in a directory hierarchy.

- `find /path/to/search -name "file_name"`: Searches for `file_name` starting from `/path/to/search`.

These commands cover a broad range of common tasks. If you have specific needs or questions about
any of these commands, feel free to ask!

You might also like