{"id":16463685,"url":"https://github.com/meqdaddev/linux-notes","last_synced_at":"2026-02-25T03:34:20.142Z","repository":{"id":223889579,"uuid":"748818363","full_name":"MeqdadDev/linux-notes","owner":"MeqdadDev","description":"Notes and Resources for Linux OS.","archived":false,"fork":false,"pushed_at":"2024-02-27T20:23:35.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-10T09:59:24.823Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MeqdadDev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-26T20:05:04.000Z","updated_at":"2024-02-22T14:09:45.000Z","dependencies_parsed_at":"2024-02-22T16:29:55.839Z","dependency_job_id":"0ebae71e-b380-4174-b736-b51a50cb17cf","html_url":"https://github.com/MeqdadDev/linux-notes","commit_stats":null,"previous_names":["meqdaddev/linux-notes"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MeqdadDev%2Flinux-notes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MeqdadDev%2Flinux-notes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MeqdadDev%2Flinux-notes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MeqdadDev%2Flinux-notes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MeqdadDev","download_url":"https://codeload.github.com/MeqdadDev/linux-notes/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241008097,"owners_count":19893108,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T11:15:11.120Z","updated_at":"2025-10-29T15:23:42.115Z","avatar_url":"https://github.com/MeqdadDev.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Linux Notes\nNotes and Resources for Linux OS.\n\n```\n _        _ _ _   _   _   _   _  __  __\n| |      |__ __| | \\ | | | | | | \\ \\/ /\n| |        | |   |  \\| | | | | |  \\/\\/\n| |____   _| |_  | |\\  | | | | |  /\\/\\\n|______| |_ _ _| |_| \\_|  \\___/  /_/\\_\\\n\n```\n## Linux History\n\nLinux was created by Linus Torvalds in 1991 as an open-source operating system kernel. Initially a hobby project, Linux rapidly evolved with contributions from developers worldwide, incorporating features from Unix-like systems and gaining stability.\n\nThroughout the mid-1990s and early 2000s, Linux gained traction in the server market due to its robustness, scalability, and cost-effectiveness. Distributions like Red Hat, Debian, and Slackware emerged, catering to various user needs.\n\nIn the late 2000s and early 2010s, Linux expanded into desktop computing and mobile devices. Desktop-oriented distributions such as Ubuntu and Linux Mint gained popularity, while Android, based on the Linux kernel, became the dominant OS for mobile devices globally.\n\nLinux solidified its position in cloud computing, powering infrastructure for major cloud providers like AWS, GCP, and Azure. Its flexibility, performance, and compatibility with virtualization technologies have made it a cornerstone of modern cloud-native architectures.\n\nToday, Linux enjoys widespread popularity across servers, desktops, embedded systems, and cloud computing. Its vibrant open-source community actively contributes to its development and improvement, emphasizing freedom, security, and innovation in the digital infrastructure landscape.\n\n## Popular Commands\n\n-------------------------------\n\n### `uptime`\n\n* __`uptime`__ - Tell how long the system has been running.\n\n__Usage Case:__\n\n```bash\nuptime\n```\n\n_Output:_\n\n```bash\n22:23:24 up  9:21,  1 user,  load average: 0.85, 1.10, 1.27\n```\n\n-------------------------------\n\n### `free`\n\n* __`free`__ - Display amount of free and used memory in the system.\n\n__Usage Case:__\n\n```bash\nfree\n```\n\n_Output:_\n\n```bash\n               total        used        free      shared  buff/cache   available\nMem:         7965944     2380788     3041184      378216     2543972     4908056\nSwap:        2097148     1104344      992804\n```\n\n-------------------------------\n\n### `date`\n\n* __`date`__ - print or set the system date and time.\n\n__Usage Case:__\n\n```bash\ndate\n```\n\n_Output:_\n\n```bash\nFri 26 Jan 2024 22:32:48 IST\n```\n\n* __`date +%x`__ - print locale's date representation (e.g., 12/31/99)\n\n```bash\ndate +%x\n```\n\n_Output:_\n\n```bash\n26/01/2024\n```\n\n-------------------------------\n\n### `head`\n\n* __`head`__ - output the first part of files. (10 lines)\n\n__Usage Case:__\n\n```bash\nhead test.txt\n```\n\n_Output:_\n\n```bash\nLine 1\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\nLine 7\nLine 8\nLine 9\nLine 10\n```\n\n* __`head \u003cfile_name\u003e -n 5`__ - output the first 5 lines of file.\n\n```bash\nhead test.txt -n 5\n```\n\n_Output:_\n\n```bash\nLine 1\nLine 2\nLine 3\nLine 4\nLine 5\n```\n\n-------------------------------\n\n### `tail`\n\n* __`tail`__ - output the last part of files. (10 lines)\n\n__Usage Case:__\n\n```bash\ntail test.txt\n```\n\n_Output:_\n\n```bash\nLine 10\nLine 11\nLine 12\nLine 13\nLine 14\nLine 15\nLine 16\nLine 17\nLine 18\nLine 19\nLine 20\n```\n\n* __`tail \u003cfile_name\u003e -n 5`__ - output the last 5 lines of file.\n\n```bash\ntail test.txt -n 5\n```\n\n_Output:_\n\n```bash\nLine 1\nLine 2\nLine 3\nLine 4\nLine 5\n```\n\n-------------------------------\n\n### `history`\n\n* __`history`__ - display a list of previously executed commands in a terminal session. It shows a numbered list of commands along with their execution sequence. This command is particularly useful for reviewing and reusing commands from your command-line history.\n\n__Usage Case:__\n\n```bash\nhistory\n```\n\n_Output:_\n\n```bash\n....\n....\n....\n 1152  sudo apt-get update\n 1153  sudo apt-get upgrade\n 1154  dmesg\n 1155  sudo dmesg\n 1156  cd Desktop/\n 1157  cd Tmp/\n 1158  ls\n 1159  mkdir Meqdad\n 1160  ls\n 1161  cd Meqdad/\n 1162  ls\n 1163  sudo code .\n 1164  ls\n 1165  touch hi.txt\n 1166  python3\n 1167  python --version\n....\n....\n....\n```\n\n* __`!\u003ccommand_id\u003e`__ - Rerun a specific command from history by using an exclamation mark (!) followed by the line number.\n\nRunning `ls` command from history (line 1164):\n\n```bash\n!1164\n```\n\n_Output:_\n\n```bash\nLICENSE  README.md  hi.txt\n```\n\n-------------------------------\n\n### `touch`\n\n* __`touch`__ - Create new empty files or update the timestamp of existing files. When used to create a new file, it's followed by the name of the file you want to create.\n\n__Usage Case:__\n\n```bash\ntouch example.txt\n```\n\n-------------------------------\n\n### `man`\n\n* __`man`__ - Stands for \"manual\". It's used to display the manual pages for other commands installed on your system. These manual pages provide detailed information about commands, their options, syntax, and often include examples and explanations.\n\n```bash\nman \u003ccommand_name\u003e\n```\n\n__Usage Case:__\n\n```bash\nman ls\n```\n\n-------------------------------\n\n### `id`\n\n* __`id`__ - To display the user and group identifiers associated with the current user or a specified username. It provides information about the user's UID (User Identifier), GID (Group Identifier), and supplementary group IDs.\n\n```bash\nid [username]\n```\n\n__Usage Case:__\n\n```bash\nid meqdad\n```\n\n_Output:_\n\n```bash\nuid=1000(meqdad) gid=1000(meqdad) groups=1000(meqdad),4(adm),20(dialout),24(cdrom),27(sudo),30(dip),46(plugdev),122(lpadmin),135(lxd),136(sambashare)\n```\n\nRunning `id` command for the root user:\n \n```bash\nid root\n```\n\n_Output:_\n\n```bash\nuid=0(root) gid=0(root) groups=0(root)\n```\n\n* __`id`__ - When you run the `id` command without specifying a username, it displays information about the current user.\n\nRunning `id` command the current user (`meqdad`):\n\n```bash\nid\n```\n\n_Output:_\n\n```bash\nuid=1000(meqdad) gid=1000(meqdad) groups=1000(meqdad),4(adm),20(dialout),24(cdrom),27(sudo),30(dip),46(plugdev),122(lpadmin),135(lxd),136(sambashare)\n```\n\n-------------------------------\n\n### `useradd`\n\n* __`useradd`__ - Create a new user account.\n\n```bash\nuseradd [options] [User_name]\n```\n\n__Usage Case:__\n\n```bash\nsudo useradd meqdad\n```\n\n_Output:_\n\n```bash\nA new user account \"meqdad\" is created.\n```\n\n* __`sudo useradd -d [home_dir_path] [new_user]`__ - To give a home directory path for new users.\n\n```bash\nsudo useradd -d /home/test_user test_user\n```\n\n_Output:_\n\n```bash\nA new user account \"test_user\" is created and the Home directory is created.\n```\n\n-------------------------------\n\n### `userdel`\n\n* __`userdel`__ - Delete a user account.\n\n```bash\nuserdel [options] [User_name]\n```\n\n__Usage Case:__\n\n```bash\nsudo userdel meqdad\n```\n\n_Output:_\n\n```bash\nThe user account \"meqdad\" is deleted.\n```\n\n-------------------------------\n\n### `groupadd`\n\n* __`groupadd`__ - Create a new group.\n\n```bash\ngroupadd [options] [group_name]\n```\n\n__Usage Case:__\n\n```bash\nsudo groupadd test_group\n```\n\n_Output:_\n\n```bash\nA new group \"test_group\" is created.\n```\n\n-------------------------------\n\n### `cat /etc/passwd`\n\n* __`cat /etc/passwd`__ - Display user account information.\n\n\n__Usage Case:__\n\n```bash\ncat /etc/passwd\n```\n\nOR\n\n```bash\nvim /etc/passwd\n```\n\n_Output:_\n\n```bash\nroot:x:0:0:root:/root:/bin/bash\ndaemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin\n...\n...\n...\n```\n\n__Explanation of Output:__\n\n* Username (Login Name): daemon - This is the username or login name of the user account.\n\n* Password Placeholder: x - In modern Unix-like operating systems, the actual encrypted password is stored in the /etc/shadow file for security reasons. This placeholder (x) indicates that the password is stored in /etc/shadow.\n\n* User ID (UID): 1 - This is the user's unique numerical identifier. User IDs 0-99 are typically reserved for system users and services.\n\n* Group ID (GID): 1 - This is the primary group ID of the user. In this case, both the user ID and the group ID are 1, which is often the case for system-related accounts.\n\n* User Information: daemon - This field typically contains additional information about the user, such as the full name or description. In this example, it's the same as the username.\n\n* Home Directory: /usr/sbin - This is the path to the user's home directory. For system accounts like daemon, this might be set to a directory related to the system's operation.\n\n* Login Shell: /usr/sbin/nologin - This is the path to the user's login shell. If the user is not intended to log in interactively, a shell like /usr/sbin/nologin is used to prevent login.\n\n-------------------------------\n\n### `passwd [username]`\n\n* __`passwd [username]`__ - Change or set the password for a user account.\n\n```bash\npasswd [username]\n```\n\n__Usage Case:__\n\n```bash\npasswd meqdad\n```\n\n_Output:_\n\n```bash\nChanging password for user meqdad.\nNew password:\nRetype new password:\npasswd: password updated successfully\n```\n\n-------------------------------\n\n### `usermod`\n\n* __`usermod`__ - Modify user account settings.\n\n__Usage Case:__\n\n* Changing the login shell for user \"meqdad\" to `/bin/zsh`.\n\n```bash\nsudo usermod -s /bin/zsh meqdad\n```\n\n_Output:_\n\n```bash\nThe login shell for user \"meqdad\" is changed to \"/bin/zsh\".\n```\n\n* Adding user \"meqdad\" to the \"admin\" group.\n\n```bash\nsudo usermod -G admin meqdad\n```\n\n_Output:_\n\n```bash\nUser \"meqdad\" is added to the \"admin\" group.\n```\n\n* Adding a comment for user \"meqdad\".\n\n```bash\nsudo usermod -c \"Meqdad Dev\" meqdad\n```\n\n_Output:_\n\n```bash\nThe comment for user \"meqdad\" is updated to \"Meqdad Dev\".\n```\n\n-------------------------------\n\n\n### `chage`\n\n* __`chage`__ - Change user password expiry information.\n\n__Usage Case:__\n\n* Changing the maximum password age for user \"meqdad\" to 90 days.\n\n```bash\nsudo chage -M 90 meqdad\n```\n\n_Output:_\n\n```bash\nThe maximum password age for user \"meqdad\" is set to 90 days.\n```\n\n* Changing the maximum password age for user \"meqdad\" to 10 days with warning message on the 7th day.\n\n```bash\nsudo chage -I 10 -W 7 meqdad\n```\n\n_Output:_\n\n```bash\nThe password for user \"meqdad\" will expire in 10 days, and a warning will be issued 7 days prior.\n```\n\n* Changing the maximum password age for user \"meqdad\" to a specific date.\n\n```bash\nsudo chage -E 2024-12-31 meqdad\n```\n\n_Output:_\n\n```bash\nThe password for user \"meqdad\" is set to expire on December 31, 2024.\n```\n\n-------------------------------\n\n### `find`\n\n* __`find`__ - Search for files and directories in a directory hierarchy.\n\n```bash\nfind [directory] [options] [expression]\n```\n\n__Usage Case:__\n\n```bash\nfind /home/user -name \"*.txt\"\n```\n\n_Output:_\n\n```bash\n/home/user/file1.txt\n/home/user/directory/file2.txt\n...\n```\n\n* Removing the modified files for more than 7 days ago.\n\n```bash\nfind /var/log -type f -mtime +7 -exec rm {} \\;\n```\n\n_Output:_\n\n```bash\nRemoves all files in /var/log that were modified more than 7 days ago.\n```\n\n-------------------------------\n\n### `grep`\n\n* __`grep`__ - Search for patterns in text using regular expressions.\n\n```bash\ngrep [options] pattern [files/directories]\n```\n\n__Usage Case:__\n\n```bash\ngrep \"keyword\" file.txt\n```\n\n_Output:_\n\n```bash\nLine containing the keyword in file.txt.\n```\n* Searching for the specified pattern in all files within the given directory and its subdirectories.\n\n```bash\ngrep -r \"pattern\" /path/to/directory\n```\n\n_Output:_\n\n```bash\nLines containing the pattern in files within the directory and its subdirectories.\n```\n\n* Showing information about Python processes running on the system:\n\n```bash\nps aux | grep python\n```\n\n_Output:_\n\n```bash\nuser     12345  0.0  0.0  1234  5678 ?        S    Jan01   0:00 python script.py\nuser     23456  0.0  0.0  1234  5678 ?        S    Jan01   0:00 /usr/bin/python3 another_script.py\n```\n\n-------------------------------\n\n### `locate`\n\n* __`locate`__ - Find files by name quickly using a pre-built index of file names.\n\n```bash\nlocate [options] [pattern]\n```\n\n__Usage Case:__\n\n```bash\nlocate test.txt\n```\n\n_Output:_\n\n```bash\n/home/user/test.txt\n/var/www/html/test.txt\n...\n```\n\n* Searching for files with the \".pdf\" extension, ignoring case.\n\n```bash\nlocate -i \"*.pdf\"\n```\n\n_Output:_\n\n```bash\n/home/user/Documents/Document1.pdf\n/home/user/Documents/Document2.PDF\n...\n```\n\n* Find files with \".pdf\" extension and filter for those containing \"example\" in the filename.\n\n```bash\nlocate -i \"*.pdf\" | grep \"report\"\n```\n\n_Output:_\n\n```bash\n/home/user/Documents/annual_report.pdf\n/home/user/Downloads/example_report.pdf\n...\n```\n\n-------------------------------\n\n### `systemctl`\n\n* __`systemctl`__ - Control the systemd system and service manager.\n\n```bash\nsystemctl [options] [command] [unit]\n```\n\n__Usage Case:__\n\n```bash\nsystemctl start nginx\n```\n\n_Output:_\n\n```bash\nStarts the nginx service.\n```\n\n* To display the status of the sshd service.\n\n```bash\nsystemctl status sshd\n```\n\n_Output:_\n\n```bash\nDisplays the status of the sshd service.\n```\n\n* To start a service automatically at boot.\n\n```bash\nsystemctl enable apache2\n```\n\n_Output:_\n\n```bash\nEnables the apache2 service to start automatically at boot.\n```\n\n-------------------------------\n\n### `ps`\n\n* __`ps`__ - Report a snapshot of current processes.\n\n```bash\n.....\n```\n\n__Usage Case:__\n\n* To display a list of processes running in the current session.\n\n```bash\nps\n```\n\n_Output:_\n\n```bash\n    PID TTY          TIME CMD\n   5277 pts/1    00:00:00 bash\n   5284 pts/1    00:00:00 ps\n```\n\n* To display a detailed list of all processes, including those owned by other users.\n\n```bash\nps aux\n```\n\n_Output:_\n\n```bash\nUSER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND\nroot           1  0.1  0.1 167164 11740 ?        Ss   21:50   0:01 /sbin/init splash\nroot           2  0.0  0.0      0     0 ?        S    21:50   0:00 [kthreadd]\nroot           3  0.0  0.0      0     0 ?        I\u003c   21:50   0:00 [rcu_gp]\nroot           4  0.0  0.0      0     0 ?        I\u003c   21:50   0:00 [rcu_par_gp]\nroot           5  0.0  0.0      0     0 ?        I\u003c   21:50   0:00 [slub_flushwq]\nroot           6  0.0  0.0      0     0 ?        I\u003c   21:50   0:00 [netns]\n...\n...\nroot        1115  0.0  0.2 118256 23296 ?        Ssl  21:50   0:00 /usr/bin/python3 /usr/share/unattended-upgrades/\nmosquit+    1122  0.0  0.1  15512  8320 ?        Ss   21:50   0:00 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.\ncolord      1168  0.0  0.1 245572 13012 ?        Ssl  21:50   0:00 /usr/libexec/colord\npostgres    1214  0.0  0.3 221024 29696 ?        Ss   21:50   0:00 /usr/lib/postgresql/14/bin/\npostgres    1245  0.0  0.1 221136  9232 ?        Ss   21:50   0:00 postgres: 14/main: checkpointer\n```\n\n* To display a full-format listing of all processes with additional information.\n\n```bash\nps -ef\n```\n\n_Output:_\n\n```bash\nUID          PID    PPID  C STIME TTY          TIME CMD\nroot           1       0  0 21:50 ?        00:00:01 /sbin/init splash\nroot           2       0  0 21:50 ?        00:00:00 [kthreadd]\nroot           3       2  0 21:50 ?        00:00:00 [rcu_gp]\nroot           4       2  0 21:50 ?        00:00:00 [rcu_par_gp]\nroot           5       2  0 21:50 ?        00:00:00 [slub_flushwq]\nroot           6       2  0 21:50 ?        00:00:00 [netns]\n...\n...\nlp          1221    1103  0 21:50 ?        00:00:00 /usr/lib/cups/notifier/dbus dbus://\nrtkit       1241       1  0 21:50 ?        00:00:00 /usr/libexec/rtkit-daemon\npostgres    1245    1214  0 21:50 ?        00:00:00 postgres: 14/main: checkpointer \npostgres    1246    1214  0 21:50 ?        00:00:00 postgres: 14/main: background writer \npostgres    1247    1214  0 21:50 ?        00:00:00 postgres: 14/main: walwriter \n\n```\n\n* To display a full-format listing of all processes with additional information and filters for Python processes.\n\n```bash\nps -ef | grep python\n```\n\n_Output:_\n\n```bash\nroot        1115       1  0 21:50 ?        00:00:00 /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal\nmeqdad      5663    5277  0 22:22 pts/1    00:00:00 grep --color=auto python\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeqdaddev%2Flinux-notes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeqdaddev%2Flinux-notes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeqdaddev%2Flinux-notes/lists"}