Last active
November 6, 2019 17:06
-
-
Save i0annis/a9c57326ef88650f2fbddebb24f321b5 to your computer and use it in GitHub Desktop.
Just some notes on Bash...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################################################ | |
# # | |
# ******** Welcome to my notes on Bash Commands and Scripting ******** # | |
# # | |
# Here you will find a list of commonly used commands and a brief explanation of what they do. # | |
# The purpose of these notes are to remind the use of the commands, rather than to teach. If # | |
# you need more information type "man " before each command in the terminal. There are many # | |
# sources online you can find also. # | |
# # | |
################################################################################################ | |
## COMMANDS | |
cd - open file directory (folders) | |
pwd - print working directory (show current folder path) | |
ls - list all files and folders | |
mkdir - make a new directory (folder) | |
chmod - change file permissions (use 'chmod +x ' to make files executable) | |
* example: chmod +x /path/to/script.sh | |
* to run: ./script.sh | |
lsblk - list all devices and hard drives | |
mount - mount a device (first you may need to create a directory) | |
* example: mkdir /media/usb | |
* mount /dev/sda1 /media/usb | |
umount - (not "unmount") opposite of mount | |
cp - copy files or folders | |
cp -a /s/. /d/ - copies all files and subfolders from dir /s to dir /d | |
rsync -av - same with cp, but more advanced (ideal for backups) | |
mv - move files (similar to cut & paste) | |
mv file1 file2 - rename "file1" to "file2" | |
rm - delete files (see man for more options) | |
rm -r - delete all files and directories within folder | |
tar - file compression tool for TAR files (.tgz, .tar.gz) | |
tar -xvzf - extract compressed files | |
- #Examples: https://www.tecmint.com/18-tar-command-examples-in-linux/ | |
dpkg --install - Install .deb file | |
wget "URL" - download file from URL (must link directly to file) | |
## SCRIPTING | |
# Always start a script with #!/bin/bash in the very first line. | |
# Note that hash (#) is for comments. Any line starting with # will be ignored. | |
if [...] | |
then | |
... | |
fi | |
while [...] - while loop structure | |
do | |
... | |
... | |
done | |
function () { | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment