CTRL + C
= exit current command
COMMAND + K
= clear screen on mac
up and down arrows = generate previous commands
open .
= open current folder you're in in finder
cd [path]
= go to path
ls
= list content of path
mkdir ~/my_disk
= making a new directory
touch example.txt
= create a new file of this name
nano example.txt
= Edit a file using nano editor
touch -t 200912150000.00 your_file_name
= Changing file date of a file
mv index.html index2.html
= change file name from index.html to index2.html
mv folder1 folder2
= this will move one folder1 to folder2
open filename.html
= open file in default app
open filename.html -a “Program Name”
= change the program used ... I don't use
rm -r directoryname
= remove all files in a directory
rm directoryname
= just remove that one directory
find / -type f -name ""
= Search across file system
trash management
sudo apt install trash-cli
= installed way to quickly delete trash
drives and disks
sudo mount /dev/sda2 /www/wwwroot/files.mydomain.com
= mount, can actually mount to multiple places - mounting a drive that already has files in it will replace the files in that drive.
sudo umount -l /www/wwwroot/files.surgolink.com/
= unmount, must us the L
sudo fdisk -l
= Check disks
sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
= Details like this
ip addr show | grep 192.168
= get your device’s IP address
/dev/sda2: LABEL="5TB-WD-HDD" UUID="6014-D32F" TYPE="exfat" PARTLABEL="Elements" PARTUUID="7lkjs2eb-8sa7-4bfd-949a-30652f6aaadg"
= FSTAB EXAMPLE
ssh root@123.456.7.8 = Login to a server
nslookup domainname.com= lookup IP for a domain. I used this often ⭐
whois domainname.com= get who is info
dig domain_name= detailed information about DNS queries and responses (takes args)
host domainname.com= I think this is similar to NSLookup
curl ifconfig.me= get public ip address
sudo nano /etc/hosts= file to map domains to IP
cd /users/MyName/.ssh/and then
rm known_hosts= remove known hosts on mac (many DNS related commands in this section)
sudo netstat -tunlp= all available ports
netstat -tnlp= display which process is on each port
hostname -I= list IP addresses associated with the local hostname
arp -amight be
arp -aon Ubuntu - ist of IP addresses and their corresponding MAC
arp -a | grep -v ^?` = Grep will filter out results
sudo -s
= Operate as root
cat /etc/passwd
= Show all users ← Necessary for seeing users
less /etc/group
= see all groups
modify group usermod -a -G examplegroup exampleusername
ls -ld /www/wwwroot/here.domain.com/now
= list group
mount /dev/sdb2 /www/wwwroot/here.domain.com/b
= example for SSD:
less /etc/passwd
= List all users
stat -c "%U %G" /www/wwwroot/f.surgolink.com/Movies
= IMPORTANT WAY TO CHECK WHO OWNS a FOLDER
permissions
sudo chown -R username:username /media/username/nameofdrive
= Optionally use -R
to make chmod
recursive as well
sudo apt update
= run this first
sudo apt install proftpd
= sample install
sudo apt remove proftpd
= remove install app (but it leaves config files)
sudo apt purge proftpd
= totally remove it including the config files
Where files likely go when you install a typical app, using ProFTP as an example
/etc/proftpd/
= config files. others: apache2, nginx, php, mysql, redis
/usr/sbin/
= binary. others: same as above and also redis-server, memcached
/usr/lib/proftpd/
= modules
/var/log/proftpd/
= log files
/home/username
= home directories
/etc/init.d/
or /lib/systemd/system/
= service script that allows you to start, stop, and restart the service
sudo mount /dev/{disk_partition} /path/to/mount/point
= mounting it
sudo umount /path/to/mount/point
= unmount it
ls -l filename
= view the permissions of a file
chmod 644 filename
= change permissions for a file
chmod -R <permissions> /path/to/folder
= change all permissions inside a folder
free
= output of how memory is currently allocated
free -h
= more human readable format of the same
df
= display table of disk usage on the system
docker --version
= check version
sudo service docker start
= start
sudo service docker stop
= stop
sudo service docker restart
= restart
docker ps
= list all running containers
docker ps -a
= List all containers (including stopped ones)
docker start <container_name_or_id>
= To start a stopped container
docker stop <container_name_or_id>
= To stop a running container
docker restart <container_name_or_id>
= To restart a running container
docker rm <container_name_or_id>
= To remove a stopped container
docker rm -f <container_name_or_id>
= To stop and remove a running container in one command
/etc/apache2/sites-available/example.com.conf
= common location for this
php [path/to/php/file]
= Execute a php file
php -v
= check version
sudo apache2ctl -M | grep php
= start
/usr/lib/php/
= PHP extensions directory
/etc/php/php.ini
= PHP configuration file
mysql --version
= check version
sudo service mysql start
= start
sudo service mysql stop
= stop
sudo service mysql restart
= restart
/var/lib/mysql/
= where MySQL data files are stored
apache2 -v
= check version
sudo service apache2 start
= start
stop apache
= stop
sudo service apache2 restart
= restart
/var/www/html/
= web root directory
nginx -v
= check version
sudo service nginx start
= start
sudo service nginx stop
= stop
sudo service nginx restart
= restart
/var/www/html/
= web root directory
python --version
(Python is an interpreted language, so it doesn't have specific start/stop/reboot commands like server applications.)
perl --version
(Perl is a scripting language, so it doesn't have specific start/stop/reboot commands like server applications.)
proftpd -v
= check version (or proftpd --version
)
sudo service proftpd start
= start
sudo service proftpd stop
= stop
sudo service proftpd restart
= restart
redis-server --version
= check version
sudo service redis-server start
= start
sudo service redis-server stop
= stop
sudo service redis-server restart
= restart
memcached -h | grep "memcached -"
= check version
sudo service memcached start
= start
sudo service memcached stop
= stop
sudo service memcached restart
= restart
Essential executable binaries (commands) that are required for basic system functioning. These binaries are accessible to all users.
Contains the kernel, initial RAM disk, and other boot-related files used during the boot process.
Provides access to device files that represent hardware devices, such as disks, partitions, terminals, etc.
Contains system-wide configuration files. Important settings for various software and services are stored here.
A shell script to run specified commands on a predefined time Interval.
The home directories for regular users are located here. Each user typically has a subdirectory within /home for their personal files and configurations.
These directories hold essential shared library files that are used by the system and various applications.
Traditionally used for mounting removable media such as USB drives, CDs, DVDs, etc.
Used for temporarily mounting filesystems or other devices.
Often used for installing additional software packages or applications that are not part of the default system.
A virtual filesystem that provides information about running processes and system status. It is not an actual disk directory but a way to interact with the kernel.
The home directory for the root user, the superuser with administrative privileges.
Used for storing temporary data related to the currently running system.
Contains system binaries, primarily used by the system administrator.
Typically used to store data for services provided by the system.
Similar to /proc, it provides information about the kernel and devices. It is also not an actual disk directory.
Used for storing temporary files that are typically cleared on system reboot.
Contains user-related files, including executable binaries, libraries, documentation, and more.
Holds variable data, such as log files, spool files, and temporary files generated by various services.