Useful linux commands
Linux Terminal Ubuntu

Useful linux commands


I'll leave below also a cheat sheet :)

Own directory and user control: Here

Create a soft or symbolic link?
To create a symlink at /home/ubuntu which references the original file /var/www, use: ln -s /var/www /home/ubuntu
Create link to /var/www in the current directory do ln -s /var/www

-s command makes it a symbolic link
-n makes it possible de create a folder-type symlink

Note that wherever you currently are is where the shortcut will be created.

Upload a file/folder through ssh using Secure Copy (scp):
Use the following syntax for AWS:
scp -i <keypair> /path/to/myfile.txt [email protected]/home/ubuntu/myfile.txt

Find a document on the server:
sudo find / -name foo.txt (foo.txt is the file to search)

Get full path of a file/folder
readlink -f file.txt

Switch to root:
sudo -i

Switch user between terminals:
su - user2

Getting the Size of a Directory:
sudo du -sh /var

See you file system storage:
df -h

Remove directory:
sudo rm -rf folderName

Kill a port being used
First let's see who's using the port, as an example let's use 80.
Located the port being used via: sudo netstat -tulpn | grep :80
# Example log: tcp 0 0* LISTEN 1027/nginx -g daemo

Killed the process: sudo kill 1027


Find all files containing specific text:
grep -rnw '/path/to/somewhere/' -e 'pattern'