Basic Linux commands
‼️ To begin make sure you have a user account at CSC that is a member of a project which has access to the Puhti service.
☝🏻 You should also have already logged in to Puhti with SSH or via the Puhti web interface (and opened a login node shell).
Navigating folders
-
Now that you have logged in to Puhti, check which folder you are in by typing
pwdand hittingEnter:pwd -
Check if there are any files:
ls -
Make a directory and see if it appears:
mkdir YourNameTestFolder # replace YourName ls -
Go to that folder.
cd YourNameTestFolder # replace YourName
💡 Note: if you just type cd and the first letter of the folder name, then hit tab key, the terminal completes the name. Handy!
Exploring files
-
Download a file into this new folder. Use the command
wgetfor downloading from a URL:wget https://raw.githubusercontent.com/csc-training/csc-env-eff/master/part-1/prerequisites/my-first-file.txt -
Check what kind of file you got and what size it is using the
lscommand with some extra options:ls -lth # options are l for long format, t for sorting by time and h for convenient size units. Anything that starts with a hashtag is a comment and is not executed -
Use the
lesscommand to check out what the file looks like:less my-first-file.txt -
To exit the
lesspreview of the file, hitq.💡 Tip: Instead of
lessyou can usecatwhich prints the content of the file(s) straight into the command line. For long textslessis recommended. -
Make a copy of this file:
cp my-first-file.txt YourName-first-file.txt # replace YourName ls -lth less YourName-first-file.txt # replace YourName -
Remove the file we originally downloaded (leave your own copy).
rm my-first-file.txt ls
💡 Tip: If you don’t want to have duplicate files you can use mv to ‘move/rename’ the file. Syntax is the same: mv /path/to/source/oldname /path/to/destination/newname.
More information
- Learn how to edit that file in the next tutorial!
💡 For more information of a given command line command: type man command or command --help where command is replaced with the one that you need help with.
💡 Tip: If you remember a part of a command that you have used recently you can search for it with the command history | grep string. This will show all your used commands that have included the string string (replace this with the pattern you are searching for).