sudo chmod 666 /var/run/docker.sock #screen#################### screen --version screen //To start a screen session screen -ls //To view the list of screen output: 10835.pts-0.linuxize-desktop (Detached) 10366.pts-0.linuxize-desktop (Detached) Detach ctrl+a+d Reattach screen -r <screen-name> screen -r 10366 Uses 1-On the command prompt, type screen. 2-Run the desired program. 3-Use the key sequence Ctrl-a + Ctrl-d to detach from the screen session. 4-Reattach to the screen session by typing screen -r. #Copy : cp####################### -Folder copy sudo cp -R collection/ /var/www/html/lms/ sudo rm -R /var/www/html/lms/ sudo cp -R collection/ /var/www/html/lms/ cp 1.txt 2.txt cp 1.txt 2.txt backup cp 1.txt 2.txt ~/workspace/cmd/backup/ cp -v 1.txt 2.txt ~/workspace/cmd/backup //with Verbose cp -p *.txt backup1 //Modification time/date, Access time, File flags, File mode, User ID (UID), Group ID (GID), Access Control Lists (ACLs), Extended Attributes (EAs) cp -p filename /path/to/new/location/myfile Copying all files $ cp * /home/tom/backup : current location to backup $ cp *.doc /home/tom/backup Copying all files & folders $ cp -R * /home/tom/backup interactive option cp -i 1.txt 2.txt : ask for => cp: overwrite '2.txt'? Verbose option cp -v 1.txt 2.txt : 1.txt' -> '2.txt' Both : interactive & Verbose cp -i -v 1.txt 2.txt cp: overwrite '2.txt'? y '1.txt' -> '2.txt' #Delete : Remove Files####################### rm file_1.txt rm ./path/to/the/file/file_1.txt rm file_2.txt file_3.txt rm *.png rm *.? rm -i *.dat : -i (interactive) option. ask y/n before delete rm -f filename : -f (force) option, foreceliy delete #Remove Directories rm -d directory rm -d directory1 directory2 /path/to/directory3 rm -r directory1 directory2 directory3 :-r (recursive) option. To be clear, this removes the directories and all files and sub-directories contained within them. rm -rf directory : use the -r (recursive) and -f (force) options together. #sudo apt-get install tree tree #Remove Directories with rmdir rmdir directory rmdir directory1 directory2 directory3 rmdir /path/to/directory mkdir : Make Directory mkdir -p a/b/c/d/e rmdir -p a/b/c/d/e #Editor vi/vim only save => :w save & quit => :x, :x!, :wq!, ZZ Forceful quit => :q! #alias alias cls=clear #cat cat 1.txt | less cat > 1.txt => create (inline) cat 1.txt => open (inline) cat /etc/passwd | cut -d":" -f1,3 cd cd work cd /home/manojk/workspace/cmd/ #touch - create empty file touch f1 touch f2 f2.txt #To quickly return to your home directory, use the ~ (tilde) character as the directory name. cd ~ => Moved to (/home/manojk ) cd .. => move to parent cmd/tanvi$ cat ../ragini/1.txt //rrr cmd/ragini$ cat ../tanvi/1.txt //ttt #curl curl "manojkumar.info" #df The df command shows the size, used space, and available space on the mounted filesystems of your computer. #diff The diff command compares two text files and shows the differences between them. There are many options to tailor the display to your requirements. diff -y -W 70 s1.txt s2.txt diff -y -W 70 s1.txt s2.txt --suppress-common-lines #echo The echo command prints (echoes) a string of text to the terminal window. echo $USER echo $HOME echo $PATH #exit The exit command will close a terminal window, end the execution of a shell script, or log you out of an SSH remote access session. #find find . -name *txt find . -type f -name *txt* find . -name *ones* find . -type f -name *ones* find . -iname *wild* #finger The finger command gives you a short dump of information about a user, including the time of the user’s last login, the user's home directory, and the user account's full name. #free The free command gives you a summary of the memory usage with your computer. It does this for both the main Random Access Memory (RAM) and swap memory. free : in byte free -h : in gb #groups manojk adm cdrom sudo dip plugdev lpadmin sambashare #groups manojk manojk : manojk adm cdrom sudo dip plugdev lpadmin sambashare #gzip The gzip command compresses files. By default, it removes the original file and leaves you with the compressed version. To retain both the original and the compressed version, use the -k (keep) option. gzip -k 1.txt 1.txt.gz #history The history command lists the commands you have previously issued on the command line. You can repeat any of the commands from your history by typing an exclamation point ! and the number of the command from the history list. history : last 2000 line history 5 : last 5 line history 20 : last 20 line #man history : manual #kill The kill command allows you to terminate a process from the command line. You do this by providing the process ID (PID) of the process to kill. Don’t kill processes willy-nilly. You need to have a good reason to do so. In this example, we’ll pretend the shutter program has locked up. #passwd The passwd command lets you change the password for a user. Just type passwd to change your own password. You can also change the password of another user account, but you must use sudo. You will be asked to enter the new password twice. sudo passwd mary #ping The ping command lets you verify that you have network connectivity with another network device. It is commonly used to help troubleshoot networking issues. To use ping, provide the IP address or machine name of the other device. ping 192.168.4.18 #ps The ps command lists running processes. Using ps without any options causes it to list the processes running in the current shell. ps To see all the processes related to a particular user, use the -u (user) option. This is likely to be a long list, so for convenience pipe it through less. ps -u manojk | less To see every process that is running, use the -e (every process) option: ps -e | less #pwd Nice and simple, the pwd command prints the working directory (the current directory) from the root / directory. #shutdown The shutdown command lets you shut down or reboot your Linux system. Using shutdown with no parameters will shut down your computer in one minute. #Using shutdown with no parameters will shut down your computer in one minute. shutdown To shut down immediately, use the now parameter. shutdown now shutdown +15 Shutting down in 15 minutes! shutdown -c #SSH Use the ssh command to make a connection to a remote Linux computer and log into your account. To make a connection, you must provide your user name and the IP address or domain name of the remote computer. In this example, the user mary is logging into the computer at 192.168.4.23. Once the connection is established, she is asked for her password. ssh mary@192.168.4.23 ssh 192.168.4.23 username password exit #sudo : super user do, su : switch user The sudo command is required when performing actions that require root or superuser permissions, such as changing the password for another user. sudo passwd mary #tar With the tar command, you can create an archive file (also called a tarball) that can contain many other files. They have used the . The verbose option gives some visual feedback by listing the files to the terminal window as they are added to the archive. The -f (filename) option is followed by the desired name of the archive. In this case, it is songs.tar. -c (create) option , -v (verbose) option and -f (filename) -x (extract) option , -v (verbose) option and -f (filename) #gzip -k 1.txt //1.txt.gz gunzip 1.txt.gz //1.txt tar -cvf tanvi.tar tanvi/ tar -xvf tanvi.tar tar -cvzf songs.tar.gz tanvi/ tar -xvzf songs.tar.gz tar -cvjf songs.tar.bz2 tanvi/ tar -xvjf songs.tar.bz2 #top The top command shows you a real-time display of the data relating to your Linux machine. The top of the screen is a status summary. #uname You can obtain some system information regarding the Linux computer you’re working on with the uname command. Use the -a (all) option to see everything. Use the -s (kernel name) option to see the type of kernel. Use the -r (kernel release) option to see the kernel release. Use the -v (kernel version) option to see the kernel version. #w The w command lists the currently logged in users. #whoami Use whoami to find out who you are logged in as or who is logged # cat /etc/os-release : To get the os version