0% found this document useful (0 votes)
16 views6 pages

Essential Linux Command Overview

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)
16 views6 pages

Essential Linux Command Overview

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

Linux Command List (107)

Day 1:

File and Directory Management completed.

 ls — List directory contents.

 cd — Change directory.

 pwd — Print working directory.

 mkdir — Create a directory.

 rmdir — Remove an empty directory.

 rm — Remove files or directories.

 cp — Copy files or directories.

 mv — Move or rename files or directories.

 touch — Create an empty file or update file timestamps.

 find — Search for files and directories.

 basename — Extract the file name from a path.

 dirname — Extract the directory part of a path.

Day 2

File Viewing/Editing

 cat — Concatenate and display file contents.

 more — View file contents (paginates).

 less — View file contents (paginates with navigation).

 head — View the first few lines of a file.

 tail — View the last few lines of a file.

 vi or vim — Advanced text editor.

 awk — Pattern scanning and processing.

 sed — Stream editor for modifying files.

 cut — Remove sections from lines of text.


 sort — Sort lines of text.

 uniq — Filter duplicate lines.

Day 3

File Permissions

 chmod — Change file permissions.

 chown — Change file owner and group.

 chgrp — Change group ownership of a file.

 setfacl — Set Access Control Lists (ACLs).

 getfacl — Display Access Control Lists (ACLs).

 umask — Set default permissions for new files.

Day 4

System Information

 uname — Print system information.

 top — Display running processes.

 ps — View active processes.

 df — Display disk space usage.

 du — Display file/directory space usage.

 free — Display memory usage.

 uptime — Display system uptime.

 hostname — Show or set system’s hostname.

 lsof — List open files.

 env — Display environment variables.

 export — Set or export environment variables.

 echo — Print text or variables.

Day 5
Networking

 ping — Send ICMP echo requests to a host.

 ifconfig or ip — Display or configure network interfaces.

 netstat — Display network connections.

 curl — Transfer data from or to a server.

 wget — Download files from the web.

 scp — Securely copy files between hosts.

Day 6

Package Management

 yum update — Update all installed packages to their latest available versions.

 yum updateinfo — Display information about package updates (enhancements, bug fixes,
security updates).

 yum update --security — Apply only security updates to installed packages.

 yum check-update — Check for available package updates without installing them.

 yum upgrade — Upgrade packages, including obsolete ones.

 dnf update — Update all installed packages (YUM successor).

 dnf check-update — Check for available updates.

 dnf upgrade — Perform an update and handle obsolete packages.

 dnf updateinfo — View update details like bug fixes or security patches.

 apt-get update — Update the package list from repositories.

 apt-get upgrade — Upgrade installed packages to the newest versions.

 apt-get dist-upgrade — Perform a distribution upgrade (handles dependency changes).

 apt-get autoremove — Remove unnecessary packages and dependencies.

 apt-get clean — Clear cached files from the package repository.


Day 7

Disk Management

 lsblk — List information about block devices.

 fdisk — Partition a disk.

 mount — Mount a filesystem.

 umount — Unmount a filesystem.

 fsck — File system consistency check and repair.

 blkid — Locate/print block device attributes.

 parted — Create and manage disk partitions.

 mkfs — Create a new filesystem.

 swapoff — Disable swap space.

 swapon — Enable swap space.

Day 8

User Management

 useradd — Add a new user.

 usermod — Modify user information.

 userdel — Delete a user.

 passwd — Change user password.

 whoami — Display current logged-in user.

 id — Show user and group IDs.

 groups — Show groups for a user.

 who — Show currently logged-in users.

 last — Show last logins of users.

 finger — Display user information.

Day 9

Process Management

 kill — Terminate a process by ID.


 killall — Terminate a process by name.

 bg — Resume a job in the background.

 fg — Bring a job to the foreground.

 jobs — List active jobs.

Day 10

Archiving and Compression

 tar — Archive files.

 gzip — Compress files.

 gunzip — Decompress files.

 zip — Package and compress files.

 unzip — Extract compressed files.

Day 11

Search

 grep — Search for a pattern in files.

 find — Search for files in a directory hierarchy.

 locate — Find files by name.

 which — Locate a command.

 whereis — Locate the binary, source, and manual page for a command.

 xargs — Build and execute command lines from standard input.

Day 12

System Shutdown and Reboot

 shutdown — Shut down or reboot the system.

 reboot — Reboot the system.

 halt — Stop the system.

 poweroff — Power off the system.

 init 6 — Reboot the system.


 init 0 — Shut down the system.

Day 13

Command Chaining and Redirection

 | — Pipe output of one command as input to another.

 > — Redirect output to a file (overwrite).

 >> — Redirect output to a file (append).

 < — Redirect input from a file.

 2> — Redirect standard error to a file.

 &> — Redirect both standard output and error to a file.

 tee — Redirect output to both a file and the terminal.

 ; — Execute multiple commands sequentially.

 && — Execute the next command only if the previous one succeeds.

 || — Execute the next command only if the previous one fails.

Common questions

Powered by AI

The 'tee' command enhances command-line productivity by allowing output to be simultaneously written to a file and displayed in the terminal. This dual functionality is highly useful for logging outputs for later review while still observing the results immediately . Basic redirection (using '>' or '>>') would only send output to a file, potentially missing real-time information useful for live monitoring or interactive debugging . Thus, 'tee' provides a way to maintain real-time feedback while also preserving a record, optimizing workflow efficiency.

'setfacl' and 'getfacl' commands allow setting and viewing Access Control Lists (ACLs) which provide more granular file permission management compared to traditional numeric permissions . Traditional permissions only allow setting read, write, and execute permissions in a limited owner-group-others structure, while ACLs enable setting permissions for specific users or groups beyond this basic structure . This provides significant flexibility in permission management and ensures specific access control measures, improving security and management in complex environments where traditional permissions are insufficient.

Using 'xargs' with 'find' is advantageous when dealing with a large number of results where command-line length limitations are a concern. For instance, if you want to delete a large set of files found by 'find', using 'find' with '-exec' could fail due to a too-long command line if there are many files. 'find /path -type f | xargs rm' allows 'xargs' to batch the file list into manageable groups, mitigating these limitations . This scenario illustrates the efficiency gained from 'xargs' by handling potentially overwhelming amounts of data seamlessly without hitting command length restrictions.

The 'chmod' command modifies the permissions of files and directories, which directly impacts who can read, write, or execute them . Properly configuring permissions can prevent unauthorized access and modification, thereby enhancing system security. Conversely, improperly set permissions can expose sensitive data to unauthorized users or allow unwanted modifications, thus compromising security .

The 'df' command provides an overview of disk space usage by reporting the amount of available disk space on file systems . This information is crucial for understanding how much storage is available system-wide. On the other hand, the 'du' command displays disk usage of specific files or directories, offering a detailed breakdown that helps identify space-consuming components within the file system . Together, they provide both macro and micro views of disk usage, aiding in effective disk management.

The 'cp' command copies files or directories from one location to another while keeping the original intact . In contrast, the 'mv' command moves or renames files or directories, which involves relocating them or changing their names without leaving the originals in place . These distinctions mean 'cp' is typically used for backup purposes, whereas 'mv' is used to organize or rename files.

'tar' is primarily used for archiving multiple files into a single file without compressing them by default, although it can be combined with compression tools like 'gzip' to compress the archive . It is useful for consolidating numerous files and directories into a single archive file for easier management. Conversely, 'zip' compresses and archives files in one step, which can be more convenient for compressing and reducing the size of files simultaneously . 'tar' is often preferred in Unix-like environments for its flexibility and support for various compression methods, whereas 'zip' is widely used in environments where quick compression is needed.

The 'less' command provides more navigation capabilities than 'more' when viewing file contents. 'less' allows backward and forward scrolling through the file, making it more flexible for navigation . It also doesn't load the entire file into memory, which is beneficial for viewing large files efficiently. Meanwhile, 'more' is more limited and typically only allows forward movement in a file .

'apt-get dist-upgrade' is chosen over 'apt-get upgrade' when an administrator needs to handle changes in package dependencies. While 'apt-get upgrade' updates installed packages to the latest versions, it does not remove or install new packages that might be necessary for dependencies. On the other hand, 'apt-get dist-upgrade' performs a more intelligent process of handling dependency changes, which can involve adding or removing packages to complete upgrades . Thus, it is preferred when there are complex updates that require resolution of dependency chains or major system upgrades.

Both 'init 6' and 'reboot' commands effectively reboot the system, but they operate differently. 'init 6' is a lower-level command that re-initializes the runlevel to 6, which is the designated runlevel for rebooting the system in Unix-like systems . This involves going through the process of terminating processes orderly and reinitializing system states. The 'reboot' command is a more direct method that can be faster and more user-friendly as it typically achieves the same effect but through a more streamlined procedure . Both ensure a system restart, but 'init 6' provides more insight into the runlevel change process.

You might also like