Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
linuxfind [2021/05/12 21:44]
bpienig
linuxfind [2021/05/12 22:11]
bpienig
Line 1: Line 1:
 ====== Linux Cheat Sheet ====== ====== Linux Cheat Sheet ======
 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. 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.
- 
 ===== Basics ===== ===== Basics =====
- ==== Getting help ==== +==== Getting help ==== 
-    View the manual for target command +View the manual for target command 
 <file bash>man command</file> <file bash>man command</file>
-  * Get help with a target command (probably the same as above, but not always): +Get help with a target command (probably the same as above, but not always): 
 <file bash>command -h</file> <file bash>command -h</file>
-  * In case you forget the name of a command, print possible commands relating to any given word: +In case you forget the name of a command, print possible commands relating to any given word: 
 <file bash>apropos word</file> <file bash>apropos word</file>
-  * View index of help pages:+View index of help pages:
 <file bash>info</file> <file bash>info</file>
-===== Command Line Utilities ===== +==== Command Line Utilities ==== 
-==== Basic File and Directory Operations ==== +=== Basic File and Directory Operations === 
-  Print current working directory: +Print current working directory: 
 <file bash>pwd</file> <file bash>pwd</file>
-  * Show files in current directory: +Show files in current directory: 
 <file bash>ls</file> <file bash>ls</file>
-  * Show maximum information about all files, including hidden: +Show maximum information about all files, including hidden: 
 <file bash>ls -a</file> <file bash>ls -a</file>
-  * Recurse into subdirectories and list those as well: +Recurse into subdirectories and list those as well: 
 <file bash>ls -R</file> <file bash>ls -R</file>
-  * List files by modification time, most recent first. +List files by modification time, most recent first. 
 <file bash>ls -lt</file> <file bash>ls -lt</file>
-  * Move/rename a file or directory (be careful that you don't move the source over a destination with the same name): +Move/rename a file or directory (be careful that you don't move the source over a destination with the same name): 
 <file bash>mv source destination</file> <file bash>mv source destination</file>
-  * Delete target forever (be very careful), use -r recursive flag for directories: +Delete target forever (be very careful), use -r recursive flag for directories: 
 <file bash>rm target</file> <file bash>rm target</file>
-  * Copy file or directory: +Copy file or directory: 
 <file bash>cp source destination</file> <file bash>cp source destination</file>
-  * Mount filesytem: +Mount filesytem: 
 <file bash>mount /dev/device/name /media/device/name</file> <file bash>mount /dev/device/name /media/device/name</file>
-  * Unmount: +Unmount: 
 <file bash>umount /media/device_name</file> <file bash>umount /media/device_name</file>
-  * Forensically clone filesystems and do other low-level operations on files. Be careful with this one. Can be destructive: +Forensically clone filesystems and do other low-level operations on files. Be careful with this one. Can be destructive: 
 <file bash>dd</file> <file bash>dd</file>
-  * Work with disk partitions: +Work with disk partitions: 
 <file bash>parted</file> <file bash>parted</file>
-  * Filesystem creation tool: +Filesystem creation tool: 
 <file bash>mkfs</file> <file bash>mkfs</file>
-==== System Administration ==== +=== System Administration === 
-  Execute command as an administrator (can be destructive/insecure. Use only for system administration tasks): +Execute command as an administrator (can be destructive/insecure. Use only for system administration tasks): 
 <file bash>sudo command</file> <file bash>sudo command</file>
-  * Become system administrator: +Become system administrator: 
 <file bash>sudo -s</file> <file bash>sudo -s</file>
-  * Quit system administration: +Quit system administration: 
 <file bash>exit</file> <file bash>exit</file>
-  * Forgot to type sudo in front of a command and already hit enter? Repeat the last command using sudo: +Forgot to type sudo in front of a command and already hit enter? Repeat the last command using sudo: 
 <file bash>sudo !!</file> <file bash>sudo !!</file>
-==== Installing software from a .tgz (also known as a tarball) ==== +=== Installing software from a .tgz (also known as a tarball) === 
-  First, unzip the tarball (see section on tar, below)  +First, unzip the tarball (see section on tar, below)  
-  Next, move into unzipped directory+Next, move into unzipped directory
 <file bash>cd software_directory</file> <file bash>cd software_directory</file>
-  * Always read README first if it is provided, in case there are any modifications to the procedure outlined below: +Always read README first if it is provided, in case there are any modifications to the procedure outlined below: 
 <file bash>cat README</file> <file bash>cat README</file>
-  * Automatically check for appropriate configurations and generate a MAKE file in the directory: +Automatically check for appropriate configurations and generate a MAKE file in the directory: 
 <file bash>./configure</file> <file bash>./configure</file>
-  * Compile software. May require sudo: +Compile software. May require sudo: 
 <file bash>make</file> <file bash>make</file>
-  * Move files into their appropriate locations. May also require sudo: +Move files into their appropriate locations. May also require sudo: 
 <file bash>make install</file> <file bash>make install</file>
-  * Clean up files in directory, in case make command fails, or just to remove unnecessary cruft: +Clean up files in directory, in case make command fails, or just to remove unnecessary cruft: 
 <file bash>make clean</file> <file bash>make clean</file>
-==== Ubuntu/Debian Software repositories ====  +=== Ubuntu/Debian Software repositories === 
-  Check distro repositories for software updates: +Check distro repositories for software updates: 
 <file bash>sudo apt-get update</file> <file bash>sudo apt-get update</file>
-  * Download and install updates (update first): +Download and install updates (update first): 
 <file bash>sudo apt-get upgrade</file> <file bash>sudo apt-get upgrade</file>
-  * Search for package in the repositories: +Search for package in the repositories: 
 <file bash>apt-cache search keyword</file> <file bash>apt-cache search keyword</file>
-  * Get more detail on one specific package: +Get more detail on one specific package: 
 <file bash>apt-cache show package_name</file> <file bash>apt-cache show package_name</file>
-  * Download and install a package: +Download and install a package: 
 <file bash>sudo apt-get install package_name</file> <file bash>sudo apt-get install package_name</file>
-  * View the output of a command in a more convenient format: +View the output of a command in a more convenient format: 
 <file bash>command | less</file> <file bash>command | less</file>
-==== Working With Files ==== +=== Working With Files === 
-  Print a file in terminal: +Print a file in terminal: 
 <file bash>cat file</file> <file bash>cat file</file>
-  * Find files matching filename: +Find files matching filename: 
 <file bash>locate filename</file> <file bash>locate filename</file>
-  * See the version of a program or the location of the program +See the version of a program or the location of the program 
 <file bash>which appname</file> <file bash>which appname</file>
-  * Search through filename for matches to phrase: +Search through filename for matches to phrase: 
 <file bash>grep phrase filename</file> <file bash>grep phrase filename</file>
-  * Search through output of a command for phrase: +Search through output of a command for phrase: 
 <file bash>command | grep phrase <file bash>command | grep phrase
 </file> </file>
-==== Working With Processes ==== +=== Working With Processes === 
-  List all running processes: +List all running processes: 
 <file bash>ps -e</file> <file bash>ps -e</file>
-  * Standard system monitor showing a more extensive view of all processes and system resources: +Standard system monitor showing a more extensive view of all processes and system resources: 
 <file bash>top</file> <file bash>top</file>
-  * Like top, but with a better, cleaner interface: +Like top, but with a better, cleaner interface: 
 <file bash>htop</file> <file bash>htop</file>
-  * Stop a process from using all system resources and lagging computer: +Stop a process from using all system resources and lagging computer: 
 <file bash>renice process_name</file> <file bash>renice process_name</file>
-  * Kill misbehaving process (use sparingly, last resort, try 'renice' command first): +Kill misbehaving process (use sparingly, last resort, try 'renice' command first): 
 <file bash>pkill process name</file> <file bash>pkill process name</file>
-  * Start a process in the background +Start a process in the background 
 <file bash>command &</file> <file bash>command &</file>
-  * Start a process in the background and have it keep running after you log off +Start a process in the background and have it keep running after you log off 
 <file bash>nohup command & <file bash>nohup command &
 </file> </file>
-==== Compression and Encryption ==== +=== Compression and Encryption === 
-  Make a simple compressed backup of files or directories: +Make a simple compressed backup of files or directories: 
 <file bash>tar -cvzf backup/output.tgz target_files_or_directories</file> <file bash>tar -cvzf backup/output.tgz target_files_or_directories</file>
-  * Open a compressed .tgz or .tar.gz file: +Open a compressed .tgz or .tar.gz file: 
 <file bash>tar -xvf target.tgz</file> <file bash>tar -xvf target.tgz</file>
-  * Encrypt a file: +Encrypt a file: 
 <file bash>gpg -o outputfilename.gpg -c target_file</file> <file bash>gpg -o outputfilename.gpg -c target_file</file>
-  * Decrypt a file: +Decrypt a file: 
 <file bash>gpg -o outputfilename -d target.gpg</file> <file bash>gpg -o outputfilename -d target.gpg</file>
-  * Zip and encrypt a directory simultaneously: +Zip and encrypt a directory simultaneously: 
 <file bash>gpg-zip -o encrypted_filename.tgz.gpg -c -s file_to_be_encrypted</file> <file bash>gpg-zip -o encrypted_filename.tgz.gpg -c -s file_to_be_encrypted</file>
-===== The Bash shell ===== +==== The Bash shell ==== 
-==== File Name expansions ==== +=== File Name expansions === 
-  Current user's home directory: +Current user's home directory: 
 <file bash>~/</file> <file bash>~/</file>
-  * Current directory: +Current directory: 
 <file bash>./</file> <file bash>./</file>
-  * Parent directory: +Parent directory: 
 <file bash>../</file> <file bash>../</file>
-  * Or even (Two parent directories down): +Or even (Two parent directories down): 
 <file bash>../../</file> <file bash>../../</file>
-  * All files in target directory. (Be very careful.): +All files in target directory. (Be very careful.): 
 <file bash>/* <file bash>/*
 </file> </file>
-==== Output Redirects ==== +=== Output Redirects === 
-  Redirect output of one command into the input of another with a pipe: +Redirect output of one command into the input of another with a pipe: 
 <file bash>command_1 | command_2</file> <file bash>command_1 | command_2</file>
-  * Or even: +Or even: 
 <file bash>command_1 | command_2 | command_3</file> <file bash>command_1 | command_2 | command_3</file>
-  * Redirect output to a file: +Redirect output to a file: 
 <file bash>command > file</file> <file bash>command > file</file>
-  * Or: +Or: 
 <file bash>file > file</file> <file bash>file > file</file>
-  * Or even, to redirect in a different direction: +Or even, to redirect in a different direction: 
 <file bash>file < file</file> <file bash>file < file</file>
-  * Append output rather than writing over the target file: +Append output rather than writing over the target file: 
 <file bash>file_or_command >> file</file> <file bash>file_or_command >> file</file>
-  * Works like |, but it writes output to both target and terminal: +Works like |, but it writes output to both target and terminal: 
 <file bash>tee target</file> <file bash>tee target</file>
-  * Redirect standard output and error to /dev/null, where it is deleted. +Redirect standard output and error to /dev/null, where it is deleted. 
 <file bash>command > /dev/null 2>&1 <file bash>command > /dev/null 2>&1
 </file> </file>
-==== Controlling Execution ==== +=== Controlling Execution === 
-  Wait until command 1 is finished to execute command 2 +Wait until command 1 is finished to execute command 2 
 <file bash>command_1 ; command_2</file> <file bash>command_1 ; command_2</file>
-  * Or even: +Or even: 
 <file bash>command_1 ; command_2 ; command_3</file> <file bash>command_1 ; command_2 ; command_3</file>
-  * && acts like ; but only executes command2 if command1 indicates that it succeeded without error by returning 0. +&& acts like ; but only executes command2 if command_1 indicates that it succeeded without error by returning 0. 
 <file bash>command_1 && command_2</file> <file bash>command_1 && command_2</file>
-  * || acts like && but only executes command2 if command1 indicates an error by returning 1. +double pipes || act like && but only executes command_2 if command_1 indicates an error by returning 1. 
 <file bash>command_1 || command_2 <file bash>command_1 || command_2
 </file> </file>
-==== Bash Wildcards ==== +=== Bash Wildcards === 
-  Zero or more characters: +Zero or more characters: 
 <file bash>  * </file> <file bash>  * </file>
-  * Matches "phrase" and any number of trailing characters: +Matches "phrase" and any number of trailing characters: 
 <file bash>phrase*</file> <file bash>phrase*</file>
-  * Matches any incidences of "phrase" with any trailing or leading chars: +Matches any incidences of "phrase" with any trailing or leading chars: 
 <file bash>*phrase*</file> <file bash>*phrase*</file>
-  * Matches any one char: +Matches any one char: 
 <file bash>?</file> <file bash>?</file>
-  * Matches any of the characters listed inside brackets: +Matches any of the characters listed inside brackets: 
 <file bash>[chars]</file> <file bash>[chars]</file>
-  * Matches a range of chars between a-z: +Matches a range of chars between a-z: 
 <file bash>[a-z]</file> <file bash>[a-z]</file>
 ===== Advanced ===== ===== Advanced =====
 ==== Command Line Utilities, Continued ==== ==== Command Line Utilities, Continued ====
-==== Networking ==== +=== Networking === 
-  Configure network interfaces: +Configure network interfaces: 
 <file bash>ifconfig</file> <file bash>ifconfig</file>
-  * Configure wireless network interfaces: +Configure wireless network interfaces: 
 <file bash>iwconfig</file> <file bash>iwconfig</file>
-  * Connect to a remote server. +Connect to a remote server. 
 <file bash>ssh username@ip_address</file> <file bash>ssh username@ip_address</file>
-  * Forward X from target to current machine (Get a remote desktop. Somewhat obscure, but very useful): +Forward X from target to current machine (Get a remote desktop. Somewhat obscure, but very useful): 
 <file bash>ssh -X username@ip_address</file> <file bash>ssh -X username@ip_address</file>
-  * Copy files/directory over the network from one machine to another recursively: +Copy files/directory over the network from one machine to another recursively: 
 <file bash>scp -r source_filename:username@ip_address target_filename:target_username@target_ip_address</file> <file bash>scp -r source_filename:username@ip_address target_filename:target_username@target_ip_address</file>
-  * Copy only changes between files or directories (super efficient way to sync directories, works either locally or with remote servers using username@ip_address:optionalport, just like ssh): +Copy only changes between files or directories (super efficient way to sync directories, works either locally or with remote servers using username@ip_address:optionalport, just like ssh): 
 <file bash>rsync source target</file> <file bash>rsync source target</file>
-  * Check to see if target is online and responding +Check to see if target is online and responding 
 <file bash>ping ip_address</file> <file bash>ping ip_address</file>
-  * View network route to target: +View network route to target: 
 <file bash>traceroute6 ip_address</file> <file bash>traceroute6 ip_address</file>
-  * Network Monitor +Network Monitor 
 <file bash>netstat</file> <file bash>netstat</file>
-  * View firewall rules +View firewall rules 
 <file bash>iptables -L</file> <file bash>iptables -L</file>
-  * Scan this machine(localhost) to check for open ports: +Scan this machine(localhost) to check for open ports: 
 <file bash>nmap localhost</file> <file bash>nmap localhost</file>
-==== wget ==== +== wget == 
-  download a file over http: +download a file over http: 
 <file bash>wget http://example.com/folder/file</file> <file bash>wget http://example.com/folder/file</file>
-  * complete a partially downloaded file: +complete a partially downloaded file: 
 <file bash>wget -c http://example.com/folder/file</file> <file bash>wget -c http://example.com/folder/file</file>
-  * start download in background: +start download in background: 
 <file bash>wget -b wget -c http://example.com/folder/file</file> <file bash>wget -b wget -c http://example.com/folder/file</file>
-  * download a file from ftp server: +download a file from ftp server: 
 <file bash>wget --ftp-user=USER --ftp-password=PASS ftp://example.com/folder/file</file> <file bash>wget --ftp-user=USER --ftp-password=PASS ftp://example.com/folder/file</file>
-==== netcat ==== +== netcat == 
-  Listen for input from network on recieving_port, dump it to a file (insecure, but handy): +Listen for input from network on recieving_port, dump it to a file (insecure, but handy): 
 <file bash>netcat -l recieving/port > file/copied</file> <file bash>netcat -l recieving/port > file/copied</file>
-  * Pipe the output of a command to a target ip and port over the network:  +Pipe the output of a command to a target ip and port over the network:  
-<file bash>command | netcat -w number/of/seconds/before/timeout target/ip target/port</file> +<file bash>command | netcat -w number_of_seconds_before_timeout target_ip target_port</file> 
-  Use tar to compress and output a file as a stream, pipe it to a target ip and port over the network:  +Use tar to compress and output a file as a stream, pipe it to a target ip and port over the network:  
-<file bash>sudo tar -czf - filename | netcat -w number_of_seconds_before_timeout target_ip target_port +<file bash>sudo tar -czf - filename | netcat -w number_of_seconds_before_timeout target_ip target_port</file> 
-</file> +=== Users and Groups === 
-==== Users and Groups ==== +Change owner of a file or directory:  
-  Change owner of a file or directory:  +<file bash>chown user_name:group_name directory_name</file> 
-<file bash>chown user/name:group/name directory_name</file> +Change privileges over file or directory (see man page for details.) 
-  Change privileges over file or directory (see man page for details.) +
 <file bash>chmod</file> <file bash>chmod</file>
-  * Create a new user: +Create a new user: 
 <file bash>adduser</file> <file bash>adduser</file>
-  * Change user privileges (be very careful with this one): +Change user privileges (be very careful with this one): 
 <file bash>usermod</file> <file bash>usermod</file>
-  * Delete user +Delete user 
 <file bash>deluser</file> <file bash>deluser</file>
-  * Print groups: +Print groups: 
 <file bash>groups</file> <file bash>groups</file>
-  * Create a new group: +Create a new group: 
 <file bash>groupadd</file> <file bash>groupadd</file>
-  * Change group privileges: +Change group privileges: 
 <file bash>groupmod</file> <file bash>groupmod</file>
-  * Delete group: +Delete group: 
 <file bash>delgroup</file> <file bash>delgroup</file>
-  * Temporarily become a different user: +Temporarily become a different user: 
 <file bash>su username</file> <file bash>su username</file>
-  * Print usernames of logged in users: +Print usernames of logged in users: 
 <file bash>users</file> <file bash>users</file>
-  * Write one line to another user from your terminal: +Write one line to another user from your terminal: 
 <file bash>talk</file> <file bash>talk</file>
-  * Interactive talk program to talk to other users from terminal (must be installed from repositories.): +Interactive talk program to talk to other users from terminal (must be installed from repositories.): 
 <file bash>ytalk</file> <file bash>ytalk</file>
-==== Working With Files, Continued ==== +=== Working With Files, Continued === 
-  View what processes are using what files: +View what processes are using what files: 
 <file bash>lsof</file> <file bash>lsof</file>
-  * View the differences between two files:  +View the differences between two files:  
-<file bash>diff file/1 file/2</file> +<file bash>diff file_1 file_2</file> 
-  Output the top numberoflines of file:  +Output the top numberoflines of file:  
-<file bash>head -n number/of/lines file</file> +<file bash>head -n number_of_lines file</file> 
-  Like head, but it outputs the last -n lines:  +Like head, but it outputs the last -n lines:  
-<file bash>tail -n number/of/lines file</file> +<file bash>tail -n number_of_lines file</file> 
-  Checksum a file: +Checksum a file: 
 <file bash>md5sum file</file> <file bash>md5sum file</file>
-  * Checksum every file in a directory (install this one from repositories.): +Checksum every file in a directory (install this one from repositories.): 
 <file bash>md5deep directory</file> <file bash>md5deep directory</file>
-  * Checksum a file (better algorithm with no hash collisions): +Checksum a file (better algorithm with no hash collisions): 
 <file bash>sha1sum</file> <file bash>sha1sum</file>
-  * Same operation as md5deep, but using sha1: +Same operation as md5deep, but using sha1: 
 <file bash>sha1deep</file> <file bash>sha1deep</file>
-  * Call command every few numberofseconds, and highlight difference in output:  +Call command every few numberofseconds, and highlight difference in output:  
-<file bash>watch -d -n number/of/seconds command</file> +<file bash>watch -d -n number_of_seconds command</file> 
-  Execute command, print how long it took: +Execute command, print how long it took: 
 <file bash>time command</file> <file bash>time command</file>
-  * View files in directory from largest to smallest: +View files in directory from largest to smallest: 
 <file bash>du -a directory | sort -n -r | less</file> <file bash>du -a directory | sort -n -r | less</file>
-  * remove spaces from filenames in current directory: +remove spaces from filenames in current directory: 
 <file bash>rename -n 's/[\s]/''/g' *</file> <file bash>rename -n 's/[\s]/''/g' *</file>
-  * change capitals to lowercase in filenames in current directory: +change capitals to lowercase in filenames in current directory: 
 <file bash>rename 'y/A-Z/a-z/' *</file> <file bash>rename 'y/A-Z/a-z/' *</file>
 ==== Environment and Hardware ==== ==== Environment and Hardware ====
-  * print motherboard information +print motherboard information 
 <file bash>dmidecode</file> <file bash>dmidecode</file>
-  * Print full date and time: +Print full date and time: 
 <file bash>date</file> <file bash>date</file>
-  * Print the hostname of this machine: +Print the hostname of this machine: 
 <file bash>echo $HOSTNAME</file> <file bash>echo $HOSTNAME</file>
-  * Print information about current linux distro: +Print information about current linux distro: 
 <file bash>lsb_release -a</file> <file bash>lsb_release -a</file>
-  * Or even: +Or even: 
 <file bash>more /etc/issue</file> <file bash>more /etc/issue</file>
-  * Print linux kernel version: +Print linux kernel version: 
 <file bash>uname -a</file> <file bash>uname -a</file>
-  * Print information about kernel modules: +Print information about kernel modules: 
 <file bash>lsmod</file> <file bash>lsmod</file>
-  * Configure kernel modules (never do this ;p ): +Configure kernel modules (never do this ;p ): 
 <file bash>modprobe</file> <file bash>modprobe</file>
-  * View Installed packages: +View Installed packages: 
 <file bash>dpkg --get-selections</file> <file bash>dpkg --get-selections</file>
-  * Print environment variables: +Print environment variables: 
 <file bash>printenv</file> <file bash>printenv</file>
-  * List hardware connected via PCI ports: +List hardware connected via PCI ports: 
 <file bash>lspci</file> <file bash>lspci</file>
-  * List hardware connected via USB ports: +List hardware connected via USB ports: 
 <file bash>lsusb</file> <file bash>lsusb</file>
-  * Print hardware info stored in BIOS: +Print hardware info stored in BIOS: 
 <file bash>sudo dmidecode</file> <file bash>sudo dmidecode</file>
-  * Dump captured data off of wireless card: +Dump captured data off of wireless card: 
 <file bash>dumpcap</file> <file bash>dumpcap</file>
-  * Dump info about keyboard drivers: +Dump info about keyboard drivers: 
 <file bash>dumpkeys</file> <file bash>dumpkeys</file>
-==== Ubuntu System Administration, Advanced (Continued) ==== +==== System Administration, Advanced (Continued) ==== 
-  Add a Personal Package Archive from Ubuntu Launchpad: +Add a Personal Package Archive from Ubuntu Launchpad: 
 <file bash>add-apt-repository</file> <file bash>add-apt-repository</file>
-  * Install a .deb file from command line: +Install a .deb file from command line: 
 <file bash>sudo dpkg -i package.deb <file bash>sudo dpkg -i package.deb
 </file> </file>
-==== Python ==== +==== Development ==== 
-  Update pip (Python package manager): +=== Python === 
 +Update pip (Python package manager): 
 <file bash>pip install -U pip</file> <file bash>pip install -U pip</file>
-  * search pip repos for a library: +search pip repos for a library: 
 <file bash>pip search library_name</file> <file bash>pip search library_name</file>
-  * create a virtual python environment to allow install of many different versions of the same Python modules: +create a virtual python environment to allow install of many different versions of the same Python modules: 
 <file bash>virtualenv dirname --no-site-packages</file> <file bash>virtualenv dirname --no-site-packages</file>
-  * connect to a virtual python environment +connect to a virtual python environment 
 <file bash>source dirname/bin/activate</file> <file bash>source dirname/bin/activate</file>
-  * disconnect from a virtual python environment: +disconnect from a virtual python environment: 
 <file bash>deactivate</file> <file bash>deactivate</file>
-  * install package into virtual python environment from outside: +install package into virtual python environment from outside: 
 <file bash>pip install packagename==version_number -E dirname</file> <file bash>pip install packagename==version_number -E dirname</file>
-  * export python virtual environment into a shareable format: +export python virtual environment into a shareable format: 
 <file bash>pip freeze -E dirname > requirements.txt</file> <file bash>pip freeze -E dirname > requirements.txt</file>
-  * import python virtual environment from a requirements.txt file: +import python virtual environment from a requirements.txt file: 
 <file bash>pip install -E dirname -r requirements.txt <file bash>pip install -E dirname -r requirements.txt
 </file> </file>
-==== git ====+=== GIT ===
   All commands must be performed in the same directory as .git folder   All commands must be performed in the same directory as .git folder
-  Start a new git project: +   
 +Start a new git project: 
 <file bash>git init <file bash>git init
 git config user.name "user_name" git config user.name "user_name"
 git config user.email "email"</file> git config user.email "email"</file>
-  * Make a copy of a git (target can be specified either locally or remotely, via any number of protocols): +Make a copy of a git (target can be specified either locally or remotely, via any number of protocols): 
 <file bash>git clone target</file> <file bash>git clone target</file>
-  * Commit changes to a git: +Commit changes to a git: 
 <file bash>git commit -m "message"</file> <file bash>git commit -m "message"</file>
-  * Get info on current repository: +Get info on current repository: 
 <file bash>git status</file> <file bash>git status</file>
-  * Show change log for current repository: +Show change log for current repository: 
 <file bash>git log</file> <file bash>git log</file>
-  * Update git directory from another repository: +Update git directory from another repository: 
 <file bash>git pull [target]</file> <file bash>git pull [target]</file>
-  * Push branch to other repository: +Push branch to other repository: 
 <file bash>git push [target]</file> <file bash>git push [target]</file>
-  * Create a new branch: +Create a new branch: 
 <file bash>git branch [branchname]</file> <file bash>git branch [branchname]</file>
-  * Switch to target branch: +Switch to target branch: 
 <file bash>git checkout [branchname]</file> <file bash>git checkout [branchname]</file>
-  * Delete a branch: +Delete a branch: 
 <file bash>git branch -d [branchname]</file> <file bash>git branch -d [branchname]</file>
-  * Merge two branches: +Merge two branches: 
 <file bash>git merge [branchname] [branchname]</file> <file bash>git merge [branchname] [branchname]</file>
-  * Show all branches of a project: +Show all branches of a project: 
 <file bash>git branch <file bash>git branch
 </file> </file>
-==== Virtualization ==== +=== MySQL === 
-  * clone a virtual machine (this works, it's been tested):  +Get help: 
-<file bash>vboxmanage clonehd virtual/machine/name.vdi --format VDI ~/target/virtual/machine_name.vdi</file> +
-  * mount a shared virtual folder:  +
-  * 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.  +
-<file bash>sudo apt-get install virtualbox-ose-guest-utils +
-sudo mount -t vboxsf name/of/shared/folder/specified/in/Virtualbox path/of/mountpoint +
-</file> +
-==== mysql ==== +
-  Get help: +
 <file bash>help</file> <file bash>help</file>
-  * Show databases: +Show databases: 
 <file bash>show databases;</file> <file bash>show databases;</file>
-  * Choose a database to use: +Choose a database to use: 
 <file bash>use database/name/here;</file> <file bash>use database/name/here;</file>
-  * Show database schema: +Show database schema: 
 <file bash>show tables;</file> <file bash>show tables;</file>
-  * Delete database: +Delete database: 
 <file bash>DROP DATABASE databasename;</file> <file bash>DROP DATABASE databasename;</file>
-  * New database: +New database: 
 <file bash>CREATE DATABASE databasename;</file> <file bash>CREATE DATABASE databasename;</file>
-  * Create a new user: +Create a new user: 
 <file bash>CREATE USER username@localhost IDENTIFIED BY 'password';</file> <file bash>CREATE USER username@localhost IDENTIFIED BY 'password';</file>
-  * Show users: +Show users: 
 <file bash>select * from mysql.user;</file> <file bash>select * from mysql.user;</file>
-  * Delete a user: +Delete a user: 
 <file bash>delete from mysql.user WHERE User='user_name';</file> <file bash>delete from mysql.user WHERE User='user_name';</file>
-  * Give user access to all tables (make them root). the "%" means that they can sign in remotely, from any machine, not just localhost.: +Give user access to all tables (make them root). the "%" means that they can sign in remotely, from any machine, not just localhost.: 
 <file bash>grant all privileges on /./ to someusr@"%" identified by 'password';</file> <file bash>grant all privileges on /./ to someusr@"%" identified by 'password';</file>
-  * give certain privileges to a user on a certain database: +give certain privileges to a user on a certain database: 
 <file bash>grant select,insert,update,delete,create,drop on somedb.* to someusr@"%" identified by 'password';</file> <file bash>grant select,insert,update,delete,create,drop on somedb.* to someusr@"%" identified by 'password';</file>
-  * Tell mysql to use new user priv policies: +Tell mysql to use new user priv policies: 
 <file bash>flush privileges;</file> <file bash>flush privileges;</file>
-  * change user password: +change user password: 
 <file bash>use mysql; <file bash>use mysql;
-update user set password='password'('newpassword') where User='user_name';</file> +update user set password=password('newpassword') where User='user_name';</file> 
-  mysql command line args:  +mysql command line args:  
-  export text file with commands to rebuild all mysql tables: +export text file with commands to rebuild all mysql tables: 
 <file bash>mysqldump databasename > dumpfilename.txt</file> <file bash>mysqldump databasename > dumpfilename.txt</file>
-  * restore from a dump: +restore from a dump: 
 <file bash>mysql -u username -p < dumpfilename.txt</file> <file bash>mysql -u username -p < dumpfilename.txt</file>
-  * dump entire database: +dump entire database: 
 <file bash>mysqldump -u username -p --opt databasename > dumpfile.sql</file> <file bash>mysqldump -u username -p --opt databasename > dumpfile.sql</file>
-  * restore from entire database dump:  +restore from entire database dump:  
-<file bash>mysql -u username -p --database=databasename < dumpfile.sql+<file bash>mysql -u username -p --database=databasename < dumpfile.sql</file> 
 +==== Virtualization ==== 
 +clone a virtual machine (this works, it's been tested):  
 +<file bash>vboxmanage clonehd virtual/machine/name.vdi --format VDI ~/target/virtual/machine_name.vdi</file> 
 +mount a shared virtual folder:  
 +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.  
 +<file bash>sudo apt-get install virtualbox-ose-guest-utils 
 +sudo mount -t vboxsf name/of/shared/folder/specified/in/Virtualbox path/of/mountpoint 
 +</file>
  
 
 linuxfind.txt · Last modified: 2021/05/12 22:14 by bpienig
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Recent changes RSS feed Driven by DokuWiki