├── Linux in easy steps.pdf ├── README.md ├── convertion.md ├── error.md ├── favorites.md ├── howto_install_remove.md ├── linuxcmd.md ├── new_server.md ├── screenshots ├── df-h.png ├── lsblk.png ├── lscpu.png ├── lsusb.png ├── os_info.png └── short_summary.png ├── special.md ├── timezone.md └── users.md /Linux in easy steps.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateors/linuxcmd/516e5073b0a5e23d2573c4fc5eb0d5652bbb8fb6/Linux in easy steps.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Linux Commands 2 | 3 | ## Info (List all the available command info ) 4 | > `$ info` 5 | 6 | ## which command gives the command location / source path 7 | `$ which ls` 8 | 9 | > output: 10 | > /usr/bin/ls 11 | 12 | ## Hard link 13 | [Link Guide](https://www.computerhope.com/unix/uln.htm) \ 14 | 15 | ``$ link fileExist.txt newLinkFile.txt`` 16 | 17 | * The file name and the file's data are two separate entities. 18 | 19 | ![link illustration](https://www.computerhope.com/unix/images/nolink-diagram.jpg) 20 | 21 | ## List all files including inode 22 | > `$ ls -li` 23 | 24 | ## How to find all hard links to a given file / Find out all hard links of inode 531188 25 | > `$ find / -inum 531188` 26 | 27 | ## Gives a list of all files which have more than one link. 28 | > `$ find . -type f -links +1 2>/dev/null` 29 | 30 | ## How can I make ls only display files? 31 | ### Method-1 32 | `$ls -p | grep -v /` \ 33 | 34 | `$ls -p | grep -v / | column` 35 | 36 | > Using ls -p tells ls to append a slash to entries which are a directory, and using grep -v / tells grep to return only lines not containing a slash. 37 | 38 | - p adds the forward slash ('/') to the directory names 39 | - r reverses the order of output 40 | - v lets grep do an inverse search to print everything except the directories (everything that doesn't have the '/' that -p put there) 41 | - column puts it in columns 42 | 43 | 44 | ### Method-2 45 | `find . -maxdepth 1 -not -type d` 46 | 47 | ### Method-3 48 | `ls -p | egrep -v /$` 49 | 50 | ### Method-4 51 | `ls -F | grep -v /` 52 | > Above command displays files, But it includes symlinks, pipes, etc. If you want to eliminate them too, you can use one of the flags mentioned below. 53 | 54 | ls -F appends symbols to filenames. These symbols show useful information about files. 55 | 56 | - @ means symbolic link (or that the file has extended attributes). 57 | - \* means executable. 58 | - = means socket. 59 | - | means named pipe. 60 | - \> means door. 61 | - / means directory. 62 | 63 | > `ls -F | grep -Ev '/|@|*|=|\|'` 64 | 65 | > `ls -F | grep -Ev '/|@|*|=|>|\|'` 66 | 67 | ## How to get package info (using package manager dpkg) 68 | `$ whatis dpkg` 69 | 70 | `$ which column` 71 | 72 | `$ dpkg -S $(which column)` 73 | 74 | ## Check the ip address 75 | `$ ip address` 76 | 77 | ## Deafult permission | umask command 78 | 79 | ### Default File Permission 80 | * Files: rw-rw-rw- (666) 81 | * Directories: rwxrwxrwx (777) 82 | 83 | #### Get the umask value 84 | >`$ umask` 85 | 86 | >Lets assume your umask value is **002** \ 87 | >octal to binary to mode \ 88 | >002 --> 010 --> -w- 89 | 90 | > Now create a file called: student.txt \ 91 | > Calculate the mode value beforehand: \ 92 | > rw- rw- rw- \ 93 | > --- --- -w- \ 94 | > ---------------- \ 95 | > rw- rw- r-- ==> 664 96 | 97 | > Now check the student.txt file permssion using ls -l or stat command 98 | `$ stat student.txt` 99 | > 100 | 101 | # Concatenate Command -cat 102 | > It reads data from the file and gives their content as output. It helps us to create, view, concatenate files 103 | 104 | > `cat > file1.txt 105 | master-academy 106 | to save and close use ctrl+d 107 | 108 | ` 109 | > `cat -n file1.txt` 110 | > show content with line numbers 111 | 112 | > `cat file1.txt > file2.txt` overright one file by another 113 | 114 | > `tac file1.txt` content display in reverse order 115 | 116 | > `cat file1.txt file2.txt` view content from multiple files 117 | 118 | > `cat file1.txt file2.txt > file3.txt` combines multiple files output into a new file 119 | 120 | > `cat file1.txt >> file2.txt` to append the file1.txt to file2.txt 121 | 122 | > `cat file1.txt | cat >> other.txt` pipeing one file output appending into other file 123 | 124 | ## Changing the Time Zone in Linux 125 | > timedatectl 126 | 127 | ### List current time zone 128 | > ls -l /etc/localtime 129 | 130 | ### List all existing time zone 131 | > timedatectl list-timezones \ 132 | > example time zone: Asia/Dhaka 133 | 134 | > sudo timedatectl set-timezone 135 | 136 | > sudo timedatectl set-timezone Asia/Dhaka 137 | 138 | ### References: 139 | * [Hard link](https://www.cyberciti.biz/faq/how-to-find-all-hard-links-in-a-directory-on-linux/) 140 | * [LS Display](https://askubuntu.com/questions/811210/how-can-i-make-ls-only-display-files) 141 | * [Unmask](https://www.youtube.com/watch?v=JYT7y_Pe9wE) 142 | -------------------------------------------------------------------------------- /convertion.md: -------------------------------------------------------------------------------- 1 | ## PPK to PEM convertion 2 | > puttygen ppkfilename.ppk -O private-openssh -o pemfilename.pem 3 | 4 | ## PEM to PPK convertion 5 | Convert a PEM .pem file to a .ppk file 6 | 7 | > puttygen pemKey.pem -o ppkKey.ppk -O private 8 | 9 | ## Resource 10 | * https://www.cyberciti.biz/faq/how-to-tar-a-file-in-linux-using-command-line 11 | * https://linuxhint.com/tar-folder-linux 12 | * https://aws.amazon.com/premiumsupport/knowledge-center/ec2-ppk-pem-conversion 13 | * https://www.howtogeek.com/248780/how-to-compress-and-extract-files-using-the-tar-command-on-linux 14 | -------------------------------------------------------------------------------- /error.md: -------------------------------------------------------------------------------- 1 | # Error codes in bash 2 | * [List all the common error codes](https://www.cyberciti.biz/faq/linux-bash-exit-status-set-exit-statusin-bash/) 3 | -------------------------------------------------------------------------------- /favorites.md: -------------------------------------------------------------------------------- 1 | ## How do i remove Filesystem root icon from favorites? 2 | > gsettings set org.gnome.shell.extensions.dash-to-dock show-mounts false 3 | 4 | 5 | ## Resource 6 | * https://ubuntuhandbook.org/index.php/2019/11/hide-mounted-drives-left-dock-ubuntu-19-10/ 7 | -------------------------------------------------------------------------------- /howto_install_remove.md: -------------------------------------------------------------------------------- 1 | ## How to install any application using command line? 2 | There are two way of doing this using the command line 3 | To install any package, just open a terminal ( Ctrl + Alt + T ) and type sudo apt-get install 4 | 5 | ### Software repositories 6 | Repository is a place where software is stored 7 | 8 | ### What is package? 9 | Files associated with a package management system. Every Linux distribution comes with a package management system, but they are not all the same. 10 | 11 | The most common method of installing apps from the command line is through software repositories using what's called a package manager. All Linux apps are distributed as packages. 12 | 13 | ### What is Dependency? 14 | What other apps it may depend on 15 | 16 | ## What is Package management system? 17 | A package management system is comprised of sets of tools and file formats that are used together to install, update, and uninstall Linux apps. 18 | 19 | > The most common package management systems are .deb .rpm .tar 20 | 21 | * Red Hat, CentOS, and Fedora all use the rpm system (.rpm files) 22 | * Debian, Ubuntu, Mint use dpkg (.deb files) 23 | * Arch Linux uses nothing but tarballs (.tar files) 24 | * Gentoo Linux uses a system called Portage 25 | 26 | ## What's inside an .rpm, .deb, or .tar file? 27 | Nothing more than plain old archive files (like .zip) that contain an application's code, instructions on how to install it, dependencies , and where its configuration files should be placed. The software that reads and executes all of those instructions is called a package manager. 28 | 29 | ## What is Package manager? 30 | A package manager keeps track of what software is installed on your computer, and allows you to easily install new software, upgrade software to newer versions, or remove software that you previously installed. 31 | 32 | ## DPKG 33 | Stands for Debian package. It is the default package manager on Ubuntu. **Debian-based distributions** all use .deb files and the **dpkg** package management system. **dpkg** is a command line way to install from a **.deb** or remove already installed packages.The downside is that **dpkg does not install missing dependency packages automatically.** 34 | 35 | ## APT 36 | * [Advanced Package Tool or APT](https://wiki.debian.org/Apt) 37 | 38 | Syntax for installing deb-files 39 | 40 | > sudo apt install path_to_deb_file 41 | 42 | > sudo dpkg -i path_to_deb_file 43 | 44 | example: 45 | > sudo apt install ./code_1.64.2-1644445741_amd64.deb 46 | 47 | we can install the required dependencies with a single command, assuming that they are available in Ubuntu’s package repository. Just run this command to install the dependencies: 48 | > sudo apt install -f 49 | 50 | ## Resource 51 | * https://itsfoss.com/install-deb-files-ubuntu/ 52 | * https://opensource.com/article/18/8/how-install-software-linux-command-line 53 | * https://ubuntuhandbook.org/index.php/2021/04/install-deb-file-ubuntu-4-ways 54 | -------------------------------------------------------------------------------- /linuxcmd.md: -------------------------------------------------------------------------------- 1 | ## What does “{} \;” mean in find (in Linux)? 2 | > it's a placeholder for each file that the find command locates (taken from here). \ 3 | 4 | ## Why setfacl while we have chmod, chown & sticky bit? 5 | > sefacl is a special command which used to set beyond non-group user accessing the file system \ 6 | > suppose we have a file called **record.txt** user **wania** is the owner of the file and is under **devops** group. \ 7 | > Another user **mostain** who is not a member of the **devops** group \ 8 | > But still we want allow him to access **record.txt** file with the write permission. *How could we achive this?* \ 9 | > We can not achive this using builtin file permission, in this scneario we can use **setacl** to achive our requirements. 10 | 11 | 12 | ## setfacl && getfacl 13 | > setfacl command sets file access control lists. \ 14 | > getfacl gets the file access information 15 | 16 | > setfacl -m u:mostain:rwx file1.txt \ 17 | > setfacl -m g:devops:r-x file1.txt 18 | 19 | ## Modifying multiple directory in a single command 20 | > setfacl -R -m u:sanzida:rX /home/mostain/{live,tutorial} 21 | 22 | ## Show the current ACL 23 | > getfacl file1.txt 24 | 25 | ## Revoke write access from all groups and all named users. (m=umask) 26 | > setfacl -m m::rx file1.txt 27 | 28 | # Reference 29 | * https://www.computerhope.com/unix/usetfacl.htm 30 | -------------------------------------------------------------------------------- /new_server.md: -------------------------------------------------------------------------------- 1 | # Linux new machine hardware information 2 | > uname -a 3 | 4 | ## Machine Hardware Architecture 5 | > uname --m 6 | 7 | ## Hardware Information with lshw 8 | > sudo lshw 9 | 10 | ## Short Summary 11 | > lshw -short 12 | 13 | 14 | ## CPU Information with lscpu 15 | > lscpu 16 | 17 | ![lscpu](./screenshots/lscpu.png) 18 | 19 | ## Block Device Information with lsblk 20 | > lsblk 21 | 22 | ![lsblk](./screenshots/lsblk.png) 23 | 24 | ## USB Device Information with lsusb 25 | > lsusb 26 | 27 | ![lsusb](./screenshots/lsusb.png) 28 | 29 | ## Disk information Human readable 30 | > df -h 31 | 32 | ![df-h](./screenshots/df-h.png) 33 | 34 | ## Check Network card information 35 | > lspci | grep -i 'eth' 36 | 37 | ## Short summary 38 | > lshw -short 39 | 40 | ![short_summary](./screenshots/short_summary.png) 41 | 42 | ## Find out the IP address 43 | > ip addr 44 | 45 | ## Command to get complete Linux OS Info 46 | > cat /etc/os-release 47 | 48 | ![os_info](./screenshots/os_info.png) 49 | -------------------------------------------------------------------------------- /screenshots/df-h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateors/linuxcmd/516e5073b0a5e23d2573c4fc5eb0d5652bbb8fb6/screenshots/df-h.png -------------------------------------------------------------------------------- /screenshots/lsblk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateors/linuxcmd/516e5073b0a5e23d2573c4fc5eb0d5652bbb8fb6/screenshots/lsblk.png -------------------------------------------------------------------------------- /screenshots/lscpu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateors/linuxcmd/516e5073b0a5e23d2573c4fc5eb0d5652bbb8fb6/screenshots/lscpu.png -------------------------------------------------------------------------------- /screenshots/lsusb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateors/linuxcmd/516e5073b0a5e23d2573c4fc5eb0d5652bbb8fb6/screenshots/lsusb.png -------------------------------------------------------------------------------- /screenshots/os_info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateors/linuxcmd/516e5073b0a5e23d2573c4fc5eb0d5652bbb8fb6/screenshots/os_info.png -------------------------------------------------------------------------------- /screenshots/short_summary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateors/linuxcmd/516e5073b0a5e23d2573c4fc5eb0d5652bbb8fb6/screenshots/short_summary.png -------------------------------------------------------------------------------- /special.md: -------------------------------------------------------------------------------- 1 | # Special commands 2 | Specially use in bash script 3 | 4 | ## The number of arguments 5 | **$#** is the number of arguments, but remember it will be different in a function. $# is the number of positional parameters passed to the script, shell, or shell function. This is because, while a shell function is running, the positional parameters are temporarily replaced with the arguments to the function. 6 | 7 | ## What does $@ mean in shell? 8 | **$@** refers to all of a shell script's command-line arguments. $1 , $2 , etc., refer to the first command-line argument, the second command-line argument, etc. Place variables in quotes if the values might have spaces in them. 9 | -------------------------------------------------------------------------------- /timezone.md: -------------------------------------------------------------------------------- 1 | ## Changing the Time Zone in Linux (tested with ubuntu 20.04) 2 | 3 | > timedatectl 4 | 5 | > ls -l /etc/localtime 6 | 7 | > timedatectl list-timezones 8 | 9 | > sudo timedatectl set-timezone 10 | 11 | > sudo timedatectl set-timezone Asia/Dhaka 12 | -------------------------------------------------------------------------------- /users.md: -------------------------------------------------------------------------------- 1 | # Linux users database format 2 | 3 | * [/etc/passwd format](https://www.cyberciti.biz/faq/understanding-etcpasswd-file-format) 4 | --------------------------------------------------------------------------------