How-tos
Working with Linux
If you have suggestions on how to improve this document, or find mistakes, please send them to labman.gw@uu.nl
Introduction
Linux is a common name for a series of operating systems based on Unix. It’s a different operating system than Windows, as it’s much closer tied to the command line interface (for Windows users: remember MS-DOS?). This has its advantages: we can have much more control about what’s going on with hardware; and it so allows for a real-time environment, which is very useful for experiments that measure e.g. reaction times.
In the labs, we use the Ubuntu Mate distribution of Linux (version 20.04). This distribution has a rich graphical interface and quite an active group of users (so if you get stuck, you might well try googling!).
How to login into Linux?
Almost every PC in the lab is a dual-boot PC: it can boot into both Windows and Linux. To use Linux, select that operating system on start-up. You can log on with your Solis-ID and password. If you can’t log on, make sure you have been added to the lab users group. See this page for details.
The terminal
The terminal is one of the programs you’ll use most on Linux. The terminal allows you to perform commands: one-line expressions that can state what action you want to take on a file or folder. The following table describes some common commands. Some preliminary stuff:
- Note that for adding a directory/file to a command, you can use the tab button to auto-complete the path (or showing possible auto-complete options).
- Useful to know is that ‘.’ denotes the current directory, and ‘~’ denotes your home directory (see some of the commands below).
- Unsure about a command? Use whatis or man to find out more about it.
Action | Command |
---|---|
Files and directories | |
show contents of the current directory | ls |
show detailed contents of current directory | ls -al |
show contents of directory | ls dirname |
move or rename file | mv oldfilename newfilename |
copy file | cp filename newfilename |
copy file to current directory | cp otherdir/filename . |
go to directory | cd dirname |
go to your home directory | cd ~ |
create new directory | mkdir dirname |
show current directory path | pwd |
remove file | rm filename |
remove (empty) directory | rmdir dirname |
remove complete directory structure | rm -rf dirname |
See what’s in a text file | |
show file contents | cat filename |
show file contents one screen at a time | more filename |
idem, scrolling back through arrow keys | less filename |
show the first 10 lines of a file | head filename |
show the last 10 lines of a file | tail filename |
Other | |
change file or directory permissions | chmod options filename |
show differences between two text files | diff filename1 filename2 |
search for pattern in file | grep "pattern" filename |
search for pattern in current directory, recursively | grep -r "pattern" . |
search for files | locate "pattern" |
basic info for a command | whatis command |
show man page for a command | man command |
show commands related to keyword | apropos keyword |
start a Zep file | zep filename |
What to do next?
You don’t necessarily have to become a Linux wizard, but of course it won’t hurt. You can follow an online tutorial, read the Wikipedia entries linked to in the introduction, but you’ll learn most from booting into Linux every once in a while and trying to use the command line for tasks you’d normally use a graphical user interface for.