BASH cheatsheet
Welcome to the BASH cheatsheet! Ever feel like you've just derped out and forgot some commands? This is what this is for.
Check the table of contents if you need help finding anything. Ctrl-F is also pretty helpful. :)
Common commands
Here you will find what I would consider the most common commands that sometimes people just forget when they boop out. I got you fam (it's actually for my sake, really).
Using "alias"
An alias allows you to reference a command to another command on the system.
Say you'd like to set "ls -la" as the default "ls". You'd simply:
alias ""ls -la"="ls"
General syntax:
To alias:
alias ["command"]=["origin"]
To unalias:
unalias ["command"]
Alias additions are not permanent and will generally disappear with a server reset. To combat this, you can save an alias change to ~/.bashrc in your local user directory.
Open ~/.bashrc in your favorite text editor and append the following:
alias ["command"]=["origin"]
Replacing whatever command with the appropriate areas.
See "man alias" for more details.
Using symlinks and hardlinks
Symbolic links allow for a person to create a sort of shortcut from a file or folder to another file or folder in another portion of your system.
There are two different types of links, hard links and symbolic links. If you notice, the name implies what they both do.
Hard links traditionally only work with files, but also physically link to the location on the drive itself by referencing the inode, not an abstract location. Symbolic links do reference such a abstract location, but as a result, when you move the destination link, it will generally become orphaned. Though, as a general result, there are generally advantages and disadvantages with using either.
To make a symbolic link to a specific file or directory:
ln -s /original/path/ /link/path/
Limitations:
Yes, you can link directories as well as files, but because of the abstract nature of symlinks, any movement or deletion of the original file will lead to the symlink becoming orphaned/abandoned. Symlinks also do support linking from different volumes. However, they don't have the advantage of a physical inode location so any modification of the original file will likely break the symlink.
To make a hard link to a specific file:
ln /original/file.path /link/file.path
Limitations:
You can't reference directories, but because hard links actually reference the inode, not the system, they are definite regardless of where you move the original file.
Anyways, that's about it for the scope of this document. If you have questions, remember to check the man docs for ln.
Diskspace commands
Something soon?!