{"id":2754,"date":"2015-10-09T03:59:55","date_gmt":"2015-10-09T03:59:55","guid":{"rendered":"https:\/\/qbytes.cloud\/?p=2754"},"modified":"2015-10-09T03:59:55","modified_gmt":"2015-10-09T03:59:55","slug":"linux-cheat-sheet","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2015\/10\/09\/linux-cheat-sheet\/","title":{"rendered":"Linux Cheat Sheet"},"content":{"rendered":"<ol>\n<li>cheat_sheet.org<\/li>\n<li>(C) William Hackmore, 2010<\/li>\n<li>The contents of this file are released under the GNU General Public License. Feel free to reuse the contents of this work, as long as the resultant works give proper attribution and are made publicly available under the GNU General Public License.<\/li>\n<li>Last updated 8\/14\/2012<\/li>\n<li>Best viewed in emacs org-mode.<\/li>\n<\/ol>\n<ul>\n<li>Command Reference:\n<ul>\n<li>Basics:\n<ul>\n<li>Getting help:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ol>\n<li>View the manual for target command<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">man &#x5B;command]\n<\/pre>\n<ol>\n<li>Get help with a target command (probably the same as above, but not always):<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">&#x5B;command] -h\n<\/pre>\n<ol>\n<li>In case you forget the name of a command, print possible commands relating to [guess]:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">apropos &#x5B;guess]\n<\/pre>\n<ol>\n<li>View index of help pages:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">info\n<\/pre>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>Command Line Utilities:\n<ul>\n<li>Basic File and Directory Operations:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ol>\n<li>Print current working directory:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">pwd\n<\/pre>\n<ol>\n<li>Show files in current directory:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">ls\n<\/pre>\n<ol>\n<li>Show maximum information about all files, including hidden:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">ls -a\n<\/pre>\n<ol>\n<li>Recurse into subdirectories and list those as well:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">ls -r\n<\/pre>\n<ol>\n<li>Move\/rename a file or directory (be careful that you don&#8217;t move the source over a destination with the same name):<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">mv &#x5B;source] &#x5B;destination]\n<\/pre>\n<ol>\n<li>Delete target forever (be very careful), use -r recursive flag for directories:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">rm &#x5B;target]\n<\/pre>\n<ol>\n<li>Copy file or directory:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">cp &#x5B;source] &#x5B;destination]\n<\/pre>\n<ol>\n<li>Mount filesytem:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">mount \/dev\/&#x5B;device name] \/media\/&#x5B;device name]\n<\/pre>\n<ol>\n<li>Unmount:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">umount \/media\/&#x5B;device name]\n<\/pre>\n<ol>\n<li>Forensically clone filesystems and do other low-level operations on files. Very dangerous:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">dd\n<\/pre>\n<ol>\n<li>Work with filesystems and partitions. (Easier, still quite dangerous):<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">fdisk\n<\/pre>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>System Administration:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ol>\n<li>Execute command as an administrator (dangerous, but necessary for system administration tasks):<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo &#x5B;command]\n<\/pre>\n<ol>\n<li>Become system administrator:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo -s\n<\/pre>\n<ol>\n<li>Quit system administration:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">exit\n<\/pre>\n<ol>\n<li>Check distro repositories for software updates:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo apt-get update\n<\/pre>\n<ol>\n<li>Download and install updates (update first):<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo apt-get upgrade\n<\/pre>\n<ol>\n<li>Search for package in the repositories:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">apt-cache search &#x5B;keyword]\n<\/pre>\n<ol>\n<li>Get more detail on one specific package:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">apt-cache show &#x5B;package name]\n<\/pre>\n<ol>\n<li>Download and install a package:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo apt-get install &#x5B;package name]\n<\/pre>\n<ol>\n<li>View the output of a command in a more convenient format:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">&#x5B;command] | less\n<\/pre>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>Working With Files:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ol>\n<li>Print a file in terminal:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">cat &#x5B;file]\n<\/pre>\n<ol>\n<li>Find files matching [filename]:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">locate &#x5B;filename]\n<\/pre>\n<ol>\n<li>Search through [filename] for matches to [phrase]:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">grep &#x5B;phrase] &#x5B;filename]\n<\/pre>\n<ol>\n<li>Search through output of a command for [phrase]:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">&#x5B;command] | grep &#x5B;phrase]\n<\/pre>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>Working With Processes:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ol>\n<li>List all running processes:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">ps -e\n<\/pre>\n<ol>\n<li>Standard system monitor showing a more extensive view of all processes and system resources:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">top\n<\/pre>\n<ol>\n<li>Like top, but with a better, cleaner interface:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">htop\n<\/pre>\n<ol>\n<li>Stop a process from using all system resources and lagging computer:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">nice &#x5B;process name]\n<\/pre>\n<ol>\n<li>Kill misbehaving process (use sparingly, last resort, try &#8216;nice&#8217; command first):<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">pkill &#x5B;process name]\n<\/pre>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>Compression and Encryption:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ol>\n<li>Make a simple compressed backup of a file or directory:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">tar -cvzf &#x5B;backup output.tgz] &#x5B;target file or directory]\n<\/pre>\n<ol>\n<li>Open a compressed .tgz or .tar.gz file:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">tar -xvf &#x5B;target.tgz]\n<\/pre>\n<ol>\n<li>Encrypt a file:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">gpg -o &#x5B;outputfilename.gpg] -c &#x5B;target file]\n<\/pre>\n<ol>\n<li>Decrypt a file:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">gpg -o &#x5B;outputfilename] -d &#x5B;target.gpg]\n<\/pre>\n<ol>\n<li>Zip and encrypt a directory simultaneously:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">gpg-zip -o encrypted-filename.tgz.gpg -c -s file-to-be-encrypted\n<\/pre>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>The Bash shell:\n<ul>\n<li>File Name expansions:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ol>\n<li>Current user&#8217;s home directory:<\/li>\n<\/ol>\n<p>~\/<\/p>\n<ol>\n<li>Current directory:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">.\/\n<\/pre>\n<ol>\n<li>Parent directory:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">..\/\n<\/pre>\n<ol>\n<li>Or even (Two parent directories down):<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">..\/..\/\n<\/pre>\n<ol>\n<li>All files in target directory. (Be very careful.):<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\/*\n<\/pre>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>Output Redirects:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ol>\n<li>Redirect output of one command into the input of another with a pipe:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">&#x5B;command 1] | &#x5B;command 2]\n<\/pre>\n<ol>\n<li>Or even:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">&#x5B;command 1] | &#x5B;command 2] | &#x5B;command 3]\n<\/pre>\n<ol>\n<li>Redirect output to a file:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">&#x5B;command] &amp;gt; file\n<\/pre>\n<ol>\n<li>Or:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">&#x5B;file] &amp;gt; &#x5B;file]\n<\/pre>\n<ol>\n<li>Or even, to redirect in a different direction:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">&#x5B;file] &amp;lt; &#x5B;file]\n<\/pre>\n<ol>\n<li>Append output rather than writing over the target file:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">&#x5B;file\/command] &amp;gt;&amp;gt; &#x5B;file]\n<\/pre>\n<ol>\n<li>Works like |, but it writes output to both target and terminal:<\/li>\n<\/ol>\n<p>tee [target]<\/p>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>Controlling Execution:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ol>\n<li>Wait until [command 1] is finished to execute [command 2]<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">&#x5B;command 1]\u00a0; &#x5B;command 2]\n<\/pre>\n<ol>\n<li>Or even:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">&#x5B;command 1]\u00a0; &#x5B;command 2]\u00a0; &#x5B;command 3]\n<\/pre>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>Wildcards:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ol>\n<li>Zero or more characters:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">*\n<\/pre>\n<ol>\n<li>Matches &#8220;phrase&#8221; and any number of trailing characters:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">phrase*\n<\/pre>\n<ol>\n<li>Matches any incidences of &#8220;phrase&#8221; with any trailing or leading chars:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">*phrase*\n<\/pre>\n<ol>\n<li>Matches any one char:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">?\n<\/pre>\n<ol>\n<li>Matches any of the characters listed inside brackets:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">&#x5B;chars]\n<\/pre>\n<ol>\n<li>Matches a range of chars between a-z:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">&#x5B;a-z]\n<\/pre>\n<ul>\n<li>\n<ul>\n<li>Advanced:\n<ul>\n<li>Command Line Utilities, Continued:\n<ul>\n<li>Networking:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ol>\n<li>Configure network interfaces:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">ifconfig\n<\/pre>\n<ol>\n<li>Configure wireless network interfaces:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">iwconfig\n<\/pre>\n<ol>\n<li>Connect to a remote server.<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">ssh &#x5B;username]@&#x5B;ipaddress]\n<\/pre>\n<ol>\n<li>Forward x from target to current machine (Get a remote desktop. Very obscure and very useful):<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">ssh -x &#x5B;username]@&#x5B;ipaddress]\n<\/pre>\n<ol>\n<li>Copy files over the network from one machine to another:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">scp &#x5B;source filename]:&#x5B;username]@&#x5B;ipaddress] &#x5B;target filename]:&#x5B;target username]@&#x5B;target ipaddress]\n<\/pre>\n<ol>\n<li>Copy only changes between files or directories (super efficient way to sync directories, works either locally or with remote servers using username@ipaddress:optionalport, just like ssh):<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">rsync &#x5B;source] &#x5B;target]\n<\/pre>\n<ol>\n<li>Check to see if target is online and responding<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">ping &#x5B;ip address]\n<\/pre>\n<ol>\n<li>View network route to target:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">traceroute6 &#x5B;ip address]\n<\/pre>\n<ol>\n<li>Network Monitor<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">netstat\n<\/pre>\n<ol>\n<li>Manage standard linux firewall (advanced users only)<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">iptables\n<\/pre>\n<ol>\n<li>Scan this machine to check for open ports:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">nmap 127.0.0.1\n<\/pre>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>netcat:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ol>\n<li>Listen for input from network on [recieving port], dump it to a file (possibly insecure):<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">netcat -l &#x5B;recieving port] &amp;gt; file_copied\n<\/pre>\n<ol>\n<li>Pipe the output of a command to a target ip and port over the network:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">&#x5B;command] | netcat -w &#x5B;number of seconds before timeout] &#x5B;target ip] &#x5B;target port]\n<\/pre>\n<ol>\n<li>Use tar to compress and output a file as a stream, pipe it to a target ip and port over the network:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo tar -czf - &#x5B;filename] | netcat -w &#x5B;number of seconds before timeout] &#x5B;target ip] &#x5B;target port]\n<\/pre>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>Users and Groups:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ol>\n<li>Change owner of a file or directory:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">chown\n<\/pre>\n<ol>\n<li>Change privileges over file or directory:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">chmod\n<\/pre>\n<ol>\n<li>Create a new user:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">adduser\n<\/pre>\n<ol>\n<li>Change user privileges (be very careful with this one):<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">usermod\n<\/pre>\n<ol>\n<li>Delete user&#8221;<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">deluser\n<\/pre>\n<ol>\n<li>Print groups:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">groups\n<\/pre>\n<ol>\n<li>Create a new group:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">groupadd\n<\/pre>\n<ol>\n<li>Change group privileges:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">groupmod\n<\/pre>\n<ol>\n<li>Delete group:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">delgroup\n<\/pre>\n<ol>\n<li>Temporarily become a different user:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">su &#x5B;username]\n<\/pre>\n<ol>\n<li>Print usernames of logged in users:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">users\n<\/pre>\n<ol>\n<li>Write one line to another user from your terminal:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">talk\n<\/pre>\n<ol>\n<li>Interactive talk program to talk to other users from terminal:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">ytalk\n<\/pre>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>Working With Files, Continued:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ol>\n<li>View what processes are using what files:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">lsof\n<\/pre>\n<ol>\n<li>View the differences between two files:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">diff &#x5B;file 1] &#x5B;file 2]\n<\/pre>\n<ol>\n<li>Output the top -n lines of [file]:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">head -n &#x5B;number of lines] &#x5B;file]\n<\/pre>\n<ol>\n<li>Like head, but it outputs the last -n lines:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">tail\n<\/pre>\n<ol>\n<li>Checksum a file:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">md5sum &#x5B;file]\n<\/pre>\n<ol>\n<li>Checksum every file in a directory:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">md5deep &#x5B;directory]\n<\/pre>\n<ol>\n<li>Checksum a file (safer algorithm with no hash collisions):<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sha1sum\n<\/pre>\n<ol>\n<li>Same operation as md5deep, but using sha1:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sha1deep\n<\/pre>\n<ol>\n<li>Call [command] every -n seconds, and display output:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">watch -n &#x5B;number of seconds] &#x5B;command]\n<\/pre>\n<ol>\n<li>Execute [command], print how long it took:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">time &#x5B;command]\n<\/pre>\n<ol>\n<li>View files in home from largest to smallest:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">du -a ~\/ | sort -n -r | less\n<\/pre>\n<ol>\n<li>remove spaces from filenames in current directory<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">rename -n &#039;s\/&#x5B;\\s]\/&lt;i&gt;\/g&#039; *&lt;\/i&gt;\n<\/pre>\n<ol>\n<li>change capitals to lowercase in filenames in current directory<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">rename &#039;y\/A-Z\/a-z\/&#039; *\n<\/pre>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>Environment and Hardware:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ol>\n<li>Print full date and time:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">date\n<\/pre>\n<ol>\n<li>Print the hostname of this machine:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">echo $HOSTNAME\n<\/pre>\n<ol>\n<li>Print information about current linux distro:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">lsb_release -a\n<\/pre>\n<ol>\n<li>Print linux kernel version:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">uname -a\n<\/pre>\n<ol>\n<li>Print information about kernel modules:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">lsmod\n<\/pre>\n<ol>\n<li>Configure kernel modules (never do this):<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">modprobe\n<\/pre>\n<ol>\n<li>View Installed packages:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">dpkg --get-selections\n<\/pre>\n<ol>\n<li>Print environment variables:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">printenv \n<\/pre>\n<ol>\n<li>List hardware connected via PCI ports:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">lspci\n<\/pre>\n<ol>\n<li>List hardware connected via USB ports:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">lsusb\n<\/pre>\n<ol>\n<li>Print hardware info stored in BIOS:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo dmidecode\n<\/pre>\n<ol>\n<li>Dump captured data off of wireless card:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">dumpcap\n<\/pre>\n<ol>\n<li>Dump info about keyboard drivers:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">dumpkeys\n<\/pre>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>System Administration (Continued):<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ol>\n<li>Add a Personal Package Archive from Ubuntu Launchpad:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">add-apt-repository\n<\/pre>\n<ol>\n<li>Install a .deb file from command line:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo dpkg -i package.deb\n<\/pre>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>Python:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ol>\n<li>update pip (Python package manager):<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">pip install -U pip\n<\/pre>\n<ol>\n<li>search pip repos<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">pip\n<\/pre>\n<ol>\n<li>create a virtual python environment<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">virtualenv &#x5B;dirname] --no-site-packages\n<\/pre>\n<ol>\n<li>connect to a virtual python environment<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">source &#x5B;dirname]\/bin\/activate\n<\/pre>\n<ol>\n<li>disconnect from a python environment:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">deactivate\n<\/pre>\n<ol>\n<li>install package into virtual python environment from outsie:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">pip install &#x5B;packagename]==&#x5B;version_number] -E &#x5B;dirname]\n<\/pre>\n<ol>\n<li>export python virtual environment into a shareable format:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">pip freeze -E &#x5B;dirname] &amp;gt; requirements.txt\n<\/pre>\n<ol>\n<li>import python virtual environment from a requirements.txt file:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">pip install -E &#x5B;dirname] -r requirements.txt\n<\/pre>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>git (all commands must be performed in the same directory as .git folder):<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ol>\n<li>Start a new git project:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">git init\n<\/pre>\n<ol>\n<li>Clone a git (target can be specified either locally or remotely, via any number of protocols):<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">git clone &#x5B;target]\n<\/pre>\n<ol>\n<li>Commit changes to a git:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">git commit -m &quot;&#x5B;message]&quot;\n<\/pre>\n<ol>\n<li>Get info on current repository:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">git status\n<\/pre>\n<ol>\n<li>Show change log for current repository:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">git log\n<\/pre>\n<ol>\n<li>Update git directory from another repository:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">git pull &#x5B;target]\n<\/pre>\n<ol>\n<li>Push branch to other repository:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">git push &#x5B;target]\n<\/pre>\n<ol>\n<li>Create a new branch:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">git branch &#x5B;branchname]\n<\/pre>\n<ol>\n<li>Switch to target branch:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">git checkout &#x5B;branchname]\n<\/pre>\n<ol>\n<li>Delete a branch:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">git branch -d &#x5B;branchname]\n<\/pre>\n<ol>\n<li>Merge two branches:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">git merge &#x5B;branchname] &#x5B;branchname]\n<\/pre>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>Virtualization:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ol>\n<li>clone a virtual machine (this works, it&#8217;s been tested):<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">vboxmanage clonehd &#x5B;virtual machine name].vdi --format VDI ~\/&#x5B;target virtual machine name].vdi\n<\/pre>\n<ol>\n<li>mount a shared virtual folder:<\/li>\n<li>you need to make sure you have the right kernel modules. You can do this with modprobe, but this package works instead in a ubuntu-specific way.<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo apt-get install virtualbox-ose-guest-utils\n<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo mount -t vboxsf &#x5B;name of Shared folder specified in Virtualbox] &#x5B;path of mountpoint]\n<\/pre>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>mysql:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ol>\n<li>Get help:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">help\n<\/pre>\n<ol>\n<li>Show databases:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">show databases;\n<\/pre>\n<ol>\n<li>Choose a database to use:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">use &#x5B;database name here];\n<\/pre>\n<ol>\n<li>Show database schema:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">show tables;\n<\/pre>\n<ol>\n<li>Delete database:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">DROP DATABASE &#x5B;databasename];\n<\/pre>\n<ol>\n<li>New database:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">CREATE DATABASE &#x5B;databasename];\n<\/pre>\n<ol>\n<li>Create a new user:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">CREATE USER &#x5B;username@localhost] IDENTIFIED BY &#039;&#x5B;password]&#039;\u00a0;\n<\/pre>\n<ol>\n<li>Show users:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">select * from mysql.user;\n<\/pre>\n<ol>\n<li>Delete a user:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">delete from mysql.user WHERE User=&#039;&#x5B;user_name]&#039;;\n<\/pre>\n<ol>\n<li>Give user access to all tables (make them root). the &#8220;%&#8221; means that they can sign in remotely, from any machine, not just localhost.:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">grant all privileges on *.* to someusr@&quot;%&quot; identified by &#039;&#x5B;password]&#039;;\n<\/pre>\n<ol>\n<li>give certain privileges to a user on a certain database:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">grant select,insert,update,delete,create,drop on &#x5B;somedb].* to &#x5B;someusr]@&#x5B;&quot;%&quot;] identified by &#039;&#x5B;password]&#039;;\n<\/pre>\n<ol>\n<li>Tell mysql to use new user priv policies:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">flush privileges;\n<\/pre>\n<ol>\n<li>change user password:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">use mysql;\n<\/pre>\n<p>update user set password='[password]'(&#8216;[newpassword]&#8217;) where User='[user_name]&#8217;\u00a0;<\/p>\n<ol>\n<li>mysql command line args:<\/li>\n<\/ol>\n<ol>\n<li>export text file with commands to rebuild all mysql tables:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">mysqldump &#x5B;databasename] &amp;gt; &#x5B;dumpfilename.txt]\n<\/pre>\n<ol>\n<li>restore from a dump:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">mysql -u &#x5B;username] -p &amp;lt; &#x5B;dumpfilename.txt]\n<\/pre>\n<ol>\n<li>dump entire database:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">mysqldump -u &#x5B;username] -p --opt &#x5B;databasename] &amp;gt; &#x5B;dumpfile.sql]\n<\/pre>\n<ol>\n<li>restore from entire database dump:<\/li>\n<\/ol>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">mysql -u &#x5B;username] -p --database=&#x5B;databasename] &amp;lt; &#x5B;dumpfile.sql]\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>cheat_sheet.org (C) William Hackmore, 2010 The contents of this file are released under the GNU General Public License. Feel free to reuse the contents of this work, as long as the resultant works give proper attribution and are made publicly available under the GNU General Public License. Last updated 8\/14\/2012 Best viewed in emacs org-mode. &#8230; <a title=\"Linux Cheat Sheet\" class=\"read-more\" href=\"https:\/\/www.qbytes.cloud\/index.php\/2015\/10\/09\/linux-cheat-sheet\/\" aria-label=\"Read more about Linux Cheat Sheet\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,58],"tags":[],"class_list":["post-2754","post","type-post","status-publish","format-standard","hentry","category-administration","category-linux"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/2754","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=2754"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/2754\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=2754"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=2754"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=2754"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}