Linux basic commands
This guide aims to help you understand and use basic Linux commands to use GLiCID.
Filesystem hierarchy
/LAB-DATA/GLiCID/(labs|projects|teams|users)/xxx
/scratch/(nautilus|waves)/(labs|projects|teams|users)/xxx
Basic commands
Running a command in Linux is generally structured as follows:
<command> -option [argument] (target)
Command chaining is done with the pipe |:
<command> -option [argument] (target) | <command> | etc.
To redirect the output of a command to a file:
<command> > myfile.txt → Overwrites the file and writes into it.
<command> >> myfile.txt → Appends to the file without overwriting.
| You can autocomplete commands by using Tab to avoid typing the entire command. You can also do this with directories with some exceptions |
Linux quick cheatsheet
Command |
Help |
which <command> |
Check if the command is available in your |
pwd |
Get the current full path |
ls -al |
List the contents of the current directory |
cd |
Change directory |
cd .. |
Go up one directory |
touch a.txt |
Create an empty |
nano a.txt |
Edit the |
cat a.txt |
View the contents of the file |
less a.txt |
Same as |
cp a.txt otherfile.txt |
Copy the |
rm a.txt |
Delete the |
mv otherfile.txt file.txt |
Rename the |
rm -rf folder/ |
Delete recursively the |
User configuration files
Linux systems allow each user to personalize their environment using configuration files stored in their home directory. These files are typically hidden (prefixed with a dot .) and are executed or read automatically by the shell or specific applications.
This file is executed every time a new interactive shell session is started (e.g., when opening a terminal).
Typical use cases:
. Setting environment variables
. Defining shell aliases
. Customizing the command prompt (PS1)
. Adding paths to $PATH
File and folder permissions
$ ls -l file.txt
-rwxr-xr-x 1 user group 1234 April 7 12:34 file.txt
In Linux, each file has three types of permissions :
. Read (r): Allows reading the file content.
. Write (w): Allows modifying the file.
. Execute (x): Allows executing a file (for scripts or programs).
And have applicable groups or users to them :
. First three characters : Permissions for the file owner (U)
. Next three characters : Permissions for the group (G)
. Last three characters : Permissions for other users (O)
Processes and Performance Management
# View current processes
ps aux # Shows all processes with details
- a : Shows all processes.
- u : Shows processes with more details (user, CPU, memory).
- x : Shows all processes, even those without a terminal.
top # Displays real-time processes
htop # Enhanced version of "top", if installed
# Kill a process (replace <PID> with the process number)
kill <PID>
kill -9 <PID> # Force close
pkill <process_name> # Kill a process by name
File Search and Manipulation
# Search for a file in a directory (requires permissions on the target directory).
find /TargetDirectory -name "myfile.txt" 2>/dev/null
# Search for text in a file
grep "keyword" myfile.txt
# Find all files containing "error" in the current folder
grep -r "error" .
# View file and directory sizes
du -sh * # File/folder sizes in the current directory
# Check available disk space
df -h
Compression and Archiving
# Create a gzip archive
tar -czvf myarchive.tar.gz folder_to_add_to_archive/
# Extract a tar.gz archive
tar -xzvf myarchive.tar.gz
Transfer to and from GLiCID
| You have to run these commands from your local PC, do not run them when already connected to GLiCID |
# Transfer your local file.txt onto GLiCID
scp file.txt user@server:/path/destination/
# Copy a folder to a remote server (with -r)
scp -r folder/ user@server:/path/destination/
# Grab a file stored on GLiCID to put it on your local PC
scp user@server:/path/file.txt ./destination/