Ubuntu

From The Travis van der Font Wiki
Jump to: navigation, search

Everything Unix (not just Ubuntu and Linux) and everything command line.

Ubuntu-logo.jpg

Commands

Errors/ System Diagnosis

Create Swap Memory:

  1. sudo fallocate -l 2G /swapfile
  2. sudo chmod 600 /swapfile
  3. sudo mkswap /swapfile
  4. sudo swapon /swapfile
  5. sudo cp /etc/fstab /etc/fstab.bak
  6. echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

For more information on creating Swap Memory:

SSL with Nginx:

https://www.digitalocean.com/community/tutorials/how-to-set-up-let-s-encrypt-with-nginx-server-blocks-on-ubuntu-16-04

Unzip ZIP File Install Debian (DEB) Package [1] Remove Debian (DEB) Package [1]
unzip file.zip -d destination_folder
sudo dpkg -i DEB_PACKAGE.deb
sudo dpkg -r PACKAGE_NAME.deb
Find current user Show groups a user is in Show all existing groups
whoami
groups <username>
groups
Give user access to mounted drive storage Restart Parsoid Update Kernel (requires root)
sudo chown -R <username>:<groupname> /mnt/volume-fra1-01
service parsoid restart
apt-get update && apt-get install linux-generic
Get the mime type of a file Using composer Become root user (through sudo)
file --mime-type -b somefile.xls
php -d memory_limit=-1 composer.phar require <package/name>
sudo su
Review Server (apache) Log Errors DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
tail -f /var/log/apache2/error.log # live (last 8)
tail -8 /var/log/apache2/error.log # last 8
npm install --save-dev [email protected]
npm install --save-dev [email protected]
npm install
Clearing Cache on NPM
npm cache clean
npm cache clean --force
Reference: npmjs.org/doc/cli/npm-cache.html
Generate a self-signed certificate Generate a certificate signing request (CSR) for an existing private key

Note: CSR.csr MUST exist before this command.

Generate a certificate signing request (CSR) for an existing private key

Note: CSR.csr MUST exist before this command.

openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout privateKey.key -out certificate.crt
openssl req -out CSR.csr -key privateKey.key -new
openssl req -out CSR.csr -new -newkey rsa:2048 -nodes -keyout privateKey.key
Generate a certificate signing request based on an existing certificate

Note: certificate.crt MUST exist before this commad.

List files size sorted and print total size of <path> Generate SSH public key from the private key
openssl x509 -x509toreq -in certificate.crt -out CSR.csr -signkey privateKey.key
ls -sSh /<path> | head
ssh-keygen -y -f privatekey.pem > publickey.pem
Show a prettified list of nearby wireless APs Find the top 10 directories containing the highest number of files Ports that probably should be open in the firewall on a fresh installed machine
nmcli device wifi list
find / -type f ! -regex '^/\(dev\|proc\|run\|sys\).*' | sed '[email protected]^\(.*\)/[^/]*[email protected]\[email protected]' | sort | uniq -c | sort -n | tail -n 10
lsof -i -nlP | awk '{print $9, $8, $1}' | sed 's/.*://' | sort -u
Make a dedicated folder for each zip file
for f in *.zip; do unzip -d "${f%*.zip}" "$f"; done

Using Permissions

sudo chmod -R 777 /www/app

The -R (or --recursive) options makes it recursive.

Each number have meaning in permission. Do not give full permissions. Ideally give 755 permission for security reasons to web folder.

N   Description                      ls   binary    
0   No permissions at all            ---  000
1   Only execute                     --x  001
2   Only write                       -w-  010
3   Write and execute                -wx  011
4   Only read                        r--  100
5   Read and execute                 r-x  101
6   Read and write                   rw-  110
7   Read, write, and execute         rwx  111
  • First Number 7 - Read, write, and execute for user.
  • Second Number 5 - Read and execute for group.
  • Third Number 5 - Read and execute for other.

For more information about chmod command see: File permission

Additional information about chmod 777:

Using NPM (not really Linux)

  • npm run build — Compile and optimize the files in your assets directory
  • npm run watch — Compile assets when file changes are made, start BrowerSync session
  • npm run build:production — Compile assets for production

Reference(s)