Joffrey Wallaart & Dennis Palagin
est. 3.3 bn users
Folder == Directory
CLI == Terminal == Console == Shell == Prompt
username @hostname location cursor
pwd
This command shows your current location in the filesystem.
The list command shows the contents of the current directory
ls
To move into a directory use Change Directory
cd Documents
Pro tip: Use the [tab] key for autocompletion.
| ~ (or $HOME) | Your home directory |
| / | The root directory |
| . | The current directory |
| .. | One directory up |
Exercise:
The list command, but with an option to make it behave differently
ls -l
Options can sometimes be written in full. This is particularly useful for scripts
ls -l --all
You can also pass an argument to commands
This shows the contents of the 'Documents' folder:
ls ~/Documents
You've been using arguments before:
cd Documents
Sometimes an option can also take an argument:
ls -l --sort=extension
Where 'extension' is the argument for the option --sort.
Almost all programs have a help option that will show you the proper syntax and most common options.
ls --help
for more in-depth information pull up the manual:
man ls
Exercise:
ls -a -S -r -l /home/cli101/Documents
ls --all --sort=size --reverse -l $HOME/Documents
ls -aSrl ~/Documents
Files and folders that start with a dot are hidden.
These contain settings or user specific (local) programs and libraries. Examples are .bashrc, .profile and the .config and .local subfolders. These will become very important when you want to customize your experience. For now, they are better left alone.
Git also uses a .git subfolder in your project root to do its magic. Did you know that git was created to keep track of development on the Linux kernel?
| cat | Simply print file contents to the terminal Good for scripts or short files |
| less | More options including search By default, man uses less to output text |
cat ${filename}
less ${filename}
Exercise:
| cp ${source} ${target} | copy |
| mv ${source} ${target} | move or rename |
| mkdir ${directory} | make a directory |
| rm ${filename} | remove a file |
| rm -r ${directory} | remove a directory '-r' for recursive |
the last command will ask for confirmation for deletion of every file inside the directory. this can be remedied by using 'rm -rf'. be careful though: there is no trashbin to restore deleted files.
exercise
from normal mode
| :w | write to disk |
| :q | quit |
| :wq | write and quit |
| [i] | insert mode |
| [u] | undo |
| [esc] | back to normal mode |
| [/] | search |
| :set number | display line numbers |
exercise
cd $HOME/Exercises/vim/
./fixme.py # run the script from the local directory
vim fixme.py # run vim with the script name as argument
bug? enroll in wi4260tu to learn more!
| ${command} > ${filename} | redirect output to a new file |
| ${command} >> ${filename} | append output to a file |
| ${command} | ${command b} | use output as input for command b |
exercise:
for simplicity, we will use a language specific package manager many of you will be somewhat familiar with. python's pip will notice you are not a sysadmin and will default to installing to the .local folder in your $home.
install the ase package, we will need that in the next slide
pip install ase
exercise:
file permissions allow you to control who has what kind of access to your files. to control them you have to set mode bits.
in a nutshell, there are three levels of ownership:
remember u,g,o and a. there are also three types of permissions:
remember r,w and x
remember u,g,o (and a) and r,w,x. the command to change these is called change mode.
chmod
chmod u+x ${filename}
chmod go-wx ${filename}
chmod a+rwx ${filename} # probably not a good idea
Exercise:
try to log in to delftblue using your netid:
ssh -l ${netid} login.delftblue.tudelft.nl
there is a shorthand, but this is still a lot to type everytime you log in:
ssh ${netid}@login.delftblue.tudelft.nl
configure the client to make this a lot more user friendly.
use vim to create ~/.ssh/config:
mkdir ~/.ssh
vim ~/.ssh/config
then add:
host delftblue
user netid
hostname login.delftblue.tudelft.nl
now try:
ssh delftblue
this works for all programs that use ssh, not just command line
# passphrase recommended, but skip for course
ssh-keygen
# install public key (or lock) on server
ssh-copy-id delftblue
# at home: ssh-copy-id bastion
Now:
ssh delftblue
These often also work for other applications
For now, just copy the delftblue_examples folder to DelftBlue. The syntax is similar to cp, but can also target remote systems
scp -r ~/Exercises/ssh/delftblue_examples delftblue:~/
Now run the same command again. Can you tell why rsync is so smart?