Day - 10 of DevOps

Day - 10 of DevOps

Linux System Administration Commands - Part 4

  1. lsof:

    • The lsof command (List Open Files) is used to list information about files opened by processes.

    • Options:

      • -u user: Lists files opened by a specific user.

      • -i 4: Displays IPv4 network files.

      • -u root: Lists files opened by the root user.

      • -p 1: Displays files opened by process ID 1 (init process).

  2. top:

    • The top command provides a dynamic, real-time view of system processes, their resource usage, and other system information.

  3. kill -9 pid / kill -9 lsof -t -u cloudzone:

    • kill -9 pid: Forcefully terminates a process by sending the SIGKILL signal to the specified Process ID (pid).

    • kill -9 lsof -t -u goku;: Uses lsof to find processes owned by the user gokuland forcefully terminates them.

  4. find:

    • The find command is used to search for files and directories based on various criteria, such as name, size, or permissions.

    • Below command will list all the directories having '.txt' extension

  5. locate - needs updatedb:

    • The locate command quickly finds the location of files by searching a pre-built database. However, it requires periodic updates using the updatedb command.

  6. wc -l, wc -w, wc -c or wc -m:

    • The wc command is used to count lines, words, and bytes in a file.

      • -l: Counts the number of lines.

      • -w: Counts the number of words.

      • -c or -m: Counts the number of bytes.