CSC Computing Environment

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).

  1. Now that you have logged in to Puhti, check which folder you are in by typing pwd and hitting Enter:
pwd
  1. Check if there are any files:
ls
  1. Make a directory and see if it appears:
mkdir YourNameTestFolder    # replace YourName
ls
  1. 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

  1. Download a file into this new folder. Use the command wget for downloading from a URL:
wget https://github.com/csc-training/csc-env-eff/raw/master/_hands-on/linux_prerequisites/my-first-file.txt
  1. Check what kind of file you got and what size it is using the ls command 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
  1. Use the less command to check out what the file looks like:
less my-first-file.txt
  1. To exit the less preview of the file, hit q.

💡 Tip: Instead of less you can use cat which prints the content of the file(s) straight into the command line. For long texts less is recommended.

  1. 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
  1. 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

💡 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).