when using nano, the "^" character is referring to the control key and "M" is referring to the alt key
nano FILENAME -- to edit a file
ctrl + k -- cut textctrl + w -- find textalt + 6 -- copy textalt + a -- highlight textlsblk -- list block devices, the -f switch will give more info about a disk including the UUID
df -h -- this will check the available disk space and display it in human-readable format
du -h -- this will measure the disk space occupied by files/dirs and display it in human-readable format
parted -- utility to manage disk partitions
adduser USERNAME -- create a new user
adduser USERNAME GROUPNAME -- add a user to a group
useradd USER -- adds a user without a password
useradd --ingroup USER USER -- this will add a user in which the group for that user already exists
deluser USER -- delete a user
groupadd GROUPNAME -- create a new group
getent group GROUPNAME --shows the specified group name and group ID
delgroup GROUP -- delete a group
if you have ufw installed and get "command not found", add sudo infront of the ufw command
ufw enable -- enable the firewall
ufw start -- start the firewall
ufw status -- lists all ports and rules
ufw status | grep PORT -- this will check rules only for the specified port
ufw status numbered -- lists ports and rules along with their line number
ufw allow PORT -- replace PORT with the actual port to allow it throught the firewall
ufw allow PORT comment "enter comment" -- add a firewall rule with a comment
ufw allow PORT-PORT -- allow a range of ports
ufw deny PORT -- deny port access
ufw deny PORT comment "enter comment" -- add a firewall rule with a comment
ufw delete NUMBER -- replace NUMBER with the line number of the rule to be deleted
make sure rsync is installed on both the host and remote machine
rsync -a USER@REMOTEIP:/DIRECTORY/TO/SYNC/FROM /DIRECTORY/TO/SYNC/TO/LOCALLY -- rysnc pull command
rsync -avh HOSTDIR REMOTEUSER@REMOTEIP:/REMOTE/DIR -- rsync push command
if "command not found" try with sudo
iptables -S -- list all current iptable rules
iptables -I INPUT -p tcp --dport <PORT> -j ACCEPT -- allow a port in
permission numbers:
chmod PERMISSIONS PATH/TO/FILE -- this will change the permissions of the file being specified
chmod -r PERMISSIONS PATH/TO/DIR -- this will change the permissions of the directory and everything in it
USER:USER can be used with usernames or substituted for user ID's e.g. 1000:1000 -- the left side is the user ownershipt of the file/dir and the rightside is group ownership
chown USER:USER PATH/TO/FILE -- this will change the ownership of the specified file
chown -R USER:USER PATH/TO/DIR -- this will change the ownership of the specified directory and everything in it
useradd -m USERNAME -- create a new user for samba if desired
passwd -a USERNAME -- create a password for the new user
smbpasswd -a USERNAME -- add a user to the samba group
docker ps -- list all stopped and running docker containers
docker image ls -- list all docker images
docker container ls -- lista all docker containers
docker exec -it CONTAINER bash -- exec into a container using bash
if bash is unavailable then try sh instead
docker compose up -d -- using the cli to start a docker container in detached mode using a compose file
docker compose down -- using cli to stop a docker container
docker compose logs -f -- view docker compose logs
git init - initialize git
git checkout -b main - checkout main branch
git add README.md - add readme
git commit -m "comment" - commiting with a comment
git remote add origin <URL> - add remote origin - example URL https://github.com/aaron/example
git push -u origin main - push changes to the origin
git add . - add all files
git tag -a vx.x.x -m "version x.x.x" - add a tag and comment the tag
git push origin vx.x.x - push a tag
git push --tags - push tags
git remote remove origin - remove an origin
git remote add origin <URL REPO> - add remote origin
git branch - check the current branch
git branch -m <branch> <branch> - change branches
git rm -r --cached <foldername> - remove folder name
git rm --cached <filename> - remove file name
git add <newname> - add new name
lscpi -- list pci devices. can use options
lspci -i "keyword" -- search keywords
lspci -d ::<class> -- list devices with a specific class e.g. lspci -d ::0200 or lspci -d 8086
lspci -nn -- list vendor and device IDs you can use
lspci -v | grep -A10 "keyword -- if you need detailed info on a specific device or lspci -s <bus_id>
uname -r -- check which kernal grub loaded
rm PATH/TO/FILE -- remove a specified file
rm -r PATH/TO/DIR -- remove a directory and its contents
mv PATH/TO/FILE NEW/PATH/FILE -- this can be used to move a file to a new location and can even be used for renaming files like in the following example: mv test test1 -- this will rename test as test1
cp PATH/TO/FILE PATH/TO/COPY -- this will copy a file to the desired path
cp -r PATH/TO/DIR PATH/TO/COPY -- this will copy a directory and its contents to the specified location
ls -- list the contents of the current directory (wont show hidden files)
ls -a -- list all contents including hidden files
sudo mokutil --sb-state -- check secure boot status
nvtop -- monitor nvidia gpu stats
openssl passwd -1 -- create a password hash -- openssl passwd -1 -salt YOURSALT -- create password hash with salt (echo 'USER' | openssl passqd -1 -stdin -- can be used to view the hash)
find -- search tool e.g. find /dir/path -type f '*example*' -- this will search for any file in the specified directory including the word "example"
you can set aliases for commands and thats what this section covers
aliases can be set for commands e.g. I have "deadass" set as an alias for sudo.. both commands still work as expected.
in the home directory for whichever user you would like this set for edit the file .bashrc (or .zshrc) and at the bottom of the file in any empty space
add your line to the file to create an alias using following syntax: alias aliasName="command/s"
after creating the alias, save and exit file editing mode and use the following command for the changes to take effect:
'source ~/.bashrc' or 'source ~/.zshrc'
below is an example of setting deadass as an alias for sudo.
alias deadass="sudo"