Casper-RS avatar
Made by Casper-RS

Ubuntu Bash Commands

Files & Folders

cd (change directory)

cd /var/www/adminPanel
cd ..
cd ~

Change current working directory.

Use cd .. to go up a directory.

Use cd ~ to return to the home folder.

mkdir (make directory)

mkdir /var/www/newsite
mkdir -p /var/www/website

Create (make) a new directory.

Use the -p flag to create the maps between aswell.

If the map already exists when using the -p flag, mkdir will not override it.

ls (list)

ls /var/www
ls -l /var/www
ls -a /var/www

Shows folders inside the specified folder

Using the -lflag shows more information.

Using the -aflag shows folders that are normally hidden.

Edit files

nano

nano /var/www/adminpanel/config.yml

Opens the nano editor.

Using CTRL+Xcloses the file and prompts if you want to save it or not.

touch

touch /var/www/file.txt

Update the timestamp of an existing file or create a new file if it doesn't exist.

cat

cat /var/www/file.txt

Print the file's contents in the terminal.

Remove Files & Folders

rm

rm /var/www/config.yml
rm -r /var/www/directory

Delete a file or folder.

Using the -rflag makes you able to delete a folder instead of a file.


⚠️ Never use the -rf flag for this command! ⚠️

This flag will delete every file on your system, recursively.

rmdir

rmdir /var/www/emptyfolder

Delete an empty folder without any contents.

Permission Control

sudo

sudo nano /etc/nginx/sites-enabled/admin.conf

Execute a command with root privileges.

su

su root

Switch to the root user. You likely need to enter a password.

If you lost your root password, change it anytime with sudo passwd root

chmod

chmod 755 /var/www/admin.config

Changes file access using RWE (Read, Write, Execute) values.

Number Permission R W X
7 Read + Write + Execute r w x
6 Read + Write r w -
5 Read + Execute r - x
4 Read only r - -

chmod 755 → Owner: rwx (7), Group: r-x (5), Others: r-x (5)

Network & Fetching Data

ping

ping casper-rs.dev

Check if a website is avalaible and show the responsetime.

curl

curl https://example.com

Fetch data from a server using HTTP(S). You can download files or test API's aswell.