https://www.youtube.com/watch?v=91FhiTyEaCU
Basic intorducation crash course to understaninf terminal, bash:
https://www.youtube.com/watch?v=oxuRxtrO2Ag
https://www.youtube.com/watch?v=91FhiTyEaCU
Basic intorducation crash course to understaninf terminal, bash:
https://www.youtube.com/watch?v=oxuRxtrO2Ag
If you want you can install homebrew for installing packages on mac through command lines.
Homebrew is a package manager for mac(can think of as the pip for mac operating system); this will allow us to install software using command lines.
Instructions on installing:
https://appuals.com/how-to-fix-sudo-apt-get-command-not-found-on-macos/
Once brew is installed here's some useful command line:
brew help
brew search
brew search |wc -l
brew
this will show you a list of commands you can use
will list out all the things u can install using brew
this is a linux command that will tell you how many lines is in the search
log in first
ls and cd and cd .. to look for the location of the file
locate the file and log out
scp username@123.456.789.00:/location/of/the/file/feilname where_U_want_to_save_it(local location)
*the numbers is ip adressMore info about scp: https://linuxize.com/post/how-to-use-scp-command-to-securely-transfer-files/
Uploading files through scp
scp /local/file/location/full/path/filename.file username@123.456.789.00:/location/of/the/working/directory/on/server
Things to note:
Make sure you do not have space or () in any of the file/path names. It will run into an error.
Uploading an entire directory through scp
https://stackoverflow.com/questions/11304895/how-do-i-copy-a-folder-from-remote-to-local-using-scpscp -r /local/file/location/full/path/filename.file username@123.456.789.00:/location/of/the/working/directory/on/server
Use the mv command to move and change name of the file
mv file_u_want_to_move.txt /location/of/move/destination/
https://stackoverflow.com/questions/5142429/unix-how-to-delete-files-listed-in-a-file
Assuming that the list of files is in the file 1.txt, then do:
xargs rm -r <1.txt
The -r option causes recursion into any directories named in 1.txt.
If any files are read-only, use the -f option to force the deletion:
xargs rm -rf <1.txt
bash ./filename.sh
resources:
INFO 201: Technical Foundations of Informatics (UW): https://info201.github.io/remote-server.html
Unix commands
clear for clear screen
echo for echo content
root diectroy is where all the other directories live. root dircetory is represented by /
home directory is another special directory that is represented by a tilde (~)
list time for all
There are a couple of options that you can combine.
The -c switch sorts by time modified [1]:
-c with -lt: sort by, and show, ctime (time of last modification of file status information) with -l: show ctime and sort by name otherwise:
sort by ctime
The -u and -t switches can also be used:
-t sort by modification time
-u with -lt: sort by, and show, access time with -l: show access time and sort by name otherwise: sort by access time
You could put it all together like so [2]:
ls -ltcr # sort by and show change time, most recent last
ls -ltur # sort by and show access time, most recent last
ls -ltr # sort by date, most recent last
[1] http://unixhelp.ed.ac.uk/CGI/man-cgi?ls
[2] -r reverses the order
Shell scripting
https://www2.cisl.ucar.edu/user-support/setting-file-and-directory-permissions
https://www.pluralsight.com/blog/it-ops/linux-file-permissions
The first column is a string of 10 permission flags.
The first flag indicates, for most directory contents, that what is listed is a file (-) or a directory (d).
The other nine flags, in groups of three, indicate:
- the user’s (owner’s) permissions -rwxr-xr-x
- group members’ permissions -rwxr-xr-x
- others’ permissions -rwxr-xr-x
"Others" means everyone else who can log in on the machine.
Change group settings
chgrp new_groupname filename
chgrp new_groupname directory
Change permission
The command for changing directory permissions for group owners is similar, but add a “g” for group or “o” for users:
chmod g+w filename
chmod g-wx filename
chmod o+w filename
chmod o-rwx foldername
My most commonly used permission setting:
chgrp -R chenusers *
chmod -R gu+rx *
chmod -R g-w *
The capital R changes the setting for EVERYTHING in the folder. Even the files within another folder in that directory! This way you don't have to keep going folder within folder to change permission for everything.
chgrp -R chenusers *
Change group to our lab group so everyone in the lab can access
chmod -R gu+rx *
add read and execue permission for user and group
chmod -R g-w *
remove write permission for user and group (incase anyone accidentally overwrites the files)
Task working on: Extracting data from UKB data
Videos I found helpful:
Terminal vs. Bash vs. Command line vs. Prompt :https://www.youtube.com/watch?v=hMSByvFHOro
How computers work: https://www.youtube.com/watch?v=OAx_6-wdslM&list=PLzdnOPI1iJNcsRwJhvksEo1tJqjIqWbN-
very basic info but I found it to be a good playlist series
AWK
Lesson 12 - The Awk Programming Language: https://www.youtube.com/watch?v=_q6Uj4X_knc
Getting started with awk: https://www.youtube.com/watch?v=u8RXKFTekqw