Monday 3 October 2022

Linux basic commands

Here are some basic Linux commands along with their full forms and brief descriptions:

  1. ls (List): Lists files and directories in the current working directory. Example: ls -l (long format listing), ls -a (include hidden files), ls -h (human-readable sizes).
  2. cd (Change Directory): Changes the current working directory. Example: cd /path/to/directory.
  3. pwd (Print Working Directory): Displays the current working directory. Example: pwd.
  4. cp (Copy): Copies files and directories. Example: cp file.txt destination/.
    copy file with same  timestamp
    cp -p oldfile newfile
  5. mv (Move): Moves or renames files and directories. Example: mv file.txt new_location/, mv old_name.txt new_name.txt.
  6. rm (Remove): Deletes files and directories. Example: rm file.txt, rm -r directory/ (recursively delete a directory).
  7. mkdir (Make Directory): Creates a new directory. Example: mkdir new_directory.
  8. rmdir (Remove Directory): Deletes an empty directory. Example: rmdir empty_directory.
  9. cat (Concatenate): Displays the contents of a file. Example: cat file.txt.
  10. more or less: Pager commands to view text files page by page. Example: more file.txt, less file.txt.
  11. head and tail: Display the first or last part of a file. Example: head file.txt (displays the first few lines), tail file.txt (displays the last few lines).
  12. grep (Global Regular Expression Print): Searches for a pattern in a file or input. Example: grep "keyword" file.txt.
  13. find: Searches for files and directories based on different criteria. Example: find /path/to/search -name "filename".
  14. chmod (Change Mode): Modifies file permissions. Example: chmod +x (adds execute permission), chmod 644 file.txt (sets read-write permissions for owner, read-only for group and others).
  15. chown (Change Ownership): Changes the owner of a file or directory. Example: chown user:group file.txt.
  16. ps (Process Status): Displays information about currently running processes. 

Example: ps aux (lists all processes), ps -ef | grep process_name (search for a specific process).

  1. kill: Sends a signal to terminate a process. Example: kill PID (PID is the process ID).
  2. df (Disk Free): Shows disk space usage on file systems. Example: df -h ,df -g(displays sizes in human-readable format).
  3. free: Shows system memory usage. Example: free -h,free-g (displays sizes in human-readable format).
  4. top and htop: Displays real-time system resource usage and processes. Example: top, htop (htop is an improved version of top).
  5. ifconfig : Interface Configuration: Displays and configures network interfaces (deprecated on modern systems).
  6. ip - IP: A modern alternative to ifconfig for network configuration.
  7. ping : Sends an ICMP echo request to a host to check network connectivity.
  8. ssh - Secure Shell: Allows secure remote login to another machine over a network.
  9. scp - Secure Copy: Securely copies files between hosts over a network.
  10. tar - Tape Archive: Used to archive multiple files into a single tarball file.
  11. gzip - GNU Zip: Compresses files to reduce their size.
  12. unzip - Unzip: Extracts files from a zip archive.
  13. who - Who: Displays a list of currently logged-in users.
  14. history - History: Shows a list of previously executed commands.


No comments:

Post a Comment