Command Cheat Sheet¶
Disclaimer
The commands on this page are Linux-based, and might not be compatible with all operative systems.
General CLI Commands¶
-
sudo [command] - Abbreviation of 'superuser do'. Executes the command with admin rights.
- Ex:
sudo apt update
- Ex:
-
cd [directory/path] - Abbreviation of 'change directory' (norsk: bytt mappe).
- cd .. - goes one step up in the directory system.
- cd / - goes to the root directory in the directory system.
- cd ~ - goes to the home directory in the directory system.
- cd ./[path] - goes to the relative path in the directory system (starts in the folder you are in currently).
- cd /[path] - goes to the absolute path in the directory system (starts in the root folder).
- Ex:
cd ..orcd /home/ttm4200orcd ~
-
nano [file name] / vim [file name] - Integrated text editor. Often has to be used in combination with
sudo- Ex:
nano file.txt
- Ex:
-
touch [file name] - Creates a new empty file with the given name.
- Ex:
touch file.txt
- Ex:
-
rm [(path/)file name] - Abbreviation of 'remove'. Deletes the file with the given name in the current directory, or in the destination directory of the path.
- Ex:
rm file.txt
- Ex:
-
mkdir [directory name] - Abbreviation of 'make directory'. Creates a new directory with the given name.
- Ex:
mkdir folder1
- Ex:
-
rmdir [(path/)mappenavn] - Abbreviation of 'remove directory'. Deletes the directory with the given name in the current directory, or in the destination directory of the path.
- Ex:
rmdir mappe1
- Ex:
-
ls - Lists files and directories in the current directory (does not show hidden directories).
- ls -a -
-ais an abbreviation of all. Lists all files and directories in the current directory (including the hidden ones).
- ls -a -
-
ping [IP address/url] - Sends data packets (ICMP Ping) to the specified address and shows the response time
- Ex:
ping 172.17.0.1
- Ex:
-
traceroute [IP address] - Finds the route a packet takes from point A to point B and shows reponse times and IP addesses of the hops.
- Ex:
traceroute 172.17.0.1
- Ex:
-
ip [address/link/route/neighbor] - Shows info about IP addresses, MAC addresses, ARP tables etc.
- Ex:
ip address,ip link,ip routeorip neighbor
- Ex:
-
cat - Abbreviation of 'concatenate'. Prints the contents of a file to the terminal.
- Ex:
cat file.txt
- Ex:
-
cp [source] [destination] - Copies a file from one place to another. The source and destination can be the same directory, but then the file name needs to be changed to actually copy the file and not just overwrite the original file.
- Ex:
cp file.txt ../mappe2/file.txt
- Ex:
-
mv [source] [destination] - Moves a file from one place to another. Can also be used to change the name of a file.
- Ex:
mv file.txt ../mappe2/file.txtormv file.txt new_name.txt
- Ex:
-
man [command] - Abbreviation of manual. Shows the help page of the given command.
- Ex:
man ip
- Ex:
More commands¶
- git clone [github-url] - Makes a clone of a GitHub repo.
- Ex:
git clone https://git.ntnu.no/ie-iik/ttm4200-labs-pub.git
- Ex:
- git pull origin main - Gets the newest updates for the repo.
- jupyter lab - Starts a Jupyter Lab server process in the current directory
- Ex:
jupyter lab --no-browser --port=8888- This command will let you open the Jupyter notebook in the browser on the Sahara pc by writing
localhost:8888(given that you have already done the required setup from lab00).
- This command will let you open the Jupyter notebook in the browser on the Sahara pc by writing
- Ex: