Basic Linux Commands
The linux operating system used for the PARTICLE DAQ system can be used either in a terminal mode where you type commands or in a Windows Explorer style graphical user interface (GUI).
The Explorer-like GUI can be used for file manipulation functions (e.g., copying a file to a floppy) or deleting or moving files on the disk. It cannot be used to run the PARTICLE DAQ itself.
To begin using the Explorer-like GUI, double click on the icons on the Desktop. For the most part, Explorer mode will be familiar from Windows or MAC OS, so with a few exceptions, this information will not focus on this. Where something is much more easily done from Explorer mode, it will be highlighted here.
To begin working in the terminal mode, you will need to open a terminal. This can be accomplished by clicking on the terminal icon in the bottom icon bar, by using the main menu (footprint icon in lower left of bottom icon bar) System Tools -> New Terminal.
man This command brings up the online Unix
manual. Use it on each of the commands below.
man pwd You will see the manual for the pwd command.
pwd Shows what directory (folder) you are in.
In Linux, your home directory is /home/particle
· Let's suppose you have several data files (data1, data2 ... etc.) in a directory called muondata.
· Then suppose the directory muondata is an entry in your main home directory, /home/particle .
· If you are in your home directory (where terminals start) and type pwd, you will see /home/particle.
· If you were in the muondata directory, pwd would give you /home/particle/muondata instead
· The last slash after a directory name is optional.
As you can see, each slash (/) indicates another sub-directory.
cd Changes directories.
Examples of relative movement among directories:
cd muondata Moves down from your current directory
into the muondata sub-directory
cd .. Moves up one directory (yes, include the
two little dots)
You can also move directly into directories
Moves from ANY directory into the muondata
sub-directory of your home directory.
cd ~ Takes you back to your home directory
mkdir dirName Creates a directory with name dirName.
mkdir temp Creates the directory temp.
rmdir dirName Removes a directory dirName.
rmdir temp Removes the directory temp.
ls Lists files.
If you add -al after ls it will give more details for each file. Such as, size, permissions, owners, dates etc.
ls al You'll see a huge list of files that you can't see with the 'ls' command alone and lots of details.
If you see such a long list of files that they scroll off the terminal screen, one way to solve the problem is to use:
ls -al |more Shows one screen of file names at a time.
less data1 Dumps the contents of the data1 file to your screen with a pause at each line so you don't miss any contents as they scroll. You may move through the file using page up, page down, home and end keys. When done with less you use the q key to get back to the main terminal.
whereis data1 Shows you the location of the data1 file.
rm data1 Deletes the file data1 in the current directory.
rm -i muon* Removes all of your muon data files
(careful!! rm * will remove ALL your files)
The "-i" makes the computer prompt before removing each file. If you really want to work without a net, omit the "-i".
cp data1 newdata/ will copy the file data1 to the directory newdata (assuming it has already been created)
mv data1 newdata/ moves the file data1 to the folder newdata and deletes the old one.
The simplest way to access the floppy drive under Linux is to use the Explorer-like interface. However, there is a very important detail! To access the files on the disk, you have to mount the floppy disk, which means that the operating system will scan the disk so that it can recognize the files on it. Although your computer will be perfectly happy to allow you to remove the disk by pushing the eject key on the laptop floppy drive, this may result in unexpected actions unless you unmount the disk. For example, your files may be only partly there or not there at all! (This is no different then under Windows or DOS; its just that those operating systems hide that detail from you a little better. This is why, for example, you must eject floppy disks from the disk properties menu in Windows.)
In the Explorer interface, to mount the floppy, you just double click on the desktop icon. This will bring up a window with the contents of the floppy, and you may drag and drop files there, or take any other actions you would with normal files. (Note: unlike in Windows and MacOS, when you drag a file from your home area to the floppy, it moves the file instead of making a copy.)
To remove the disk, you must first right-click on the desktop icon, and select Unmount volume or Eject (either does the same thing). When this is complete (and it may take a long time since it may have to complete writing files to the floppy!), you may push the eject button on the floppy to remove it.
Things are more complicated by possible in the terminal mode:
mount Mounts a drive to the operating system.
Linux does not 'see' the floppy drive until
you tell it to.
mount /mnt/floppy Allows you to use the floppy drive which has directory name /mnt/floppy
cp aFile /mnt/floppy/ Copies the file aFile to the floppy disk.
ls /mnt/qfloppy/ Allows you to see what files are on your floppy.
You may run into problems moving large files onto a 1.44MB floppy disk. One option to fit larger files is to create a zip archive containing the file onto the floppy. For Example:
zip /mnt/floppy/myFile.zip muon.myDataRun
Moves the file muon.myDataRun into a zip file on the floppy named myFile.zip
After you are done and before you eject it (this is very, very important), you must unmount the floppy.
umount /mnt/qfloppy Allows you to remove the floppy disk
· Make sure you wait for the command prompt to reappear (this might take a few seconds) before ejecting the floppy.
· If you eject the floppy before you unmount the floppy, it may corrupt the data on the floppy and cause the system to be confused if you try to use the floppy again.
· If you make a mistake like this, it's probably best to reboot. Sorry.
df Shows the disk usage. This will tell you how much disk space you have left on your hard drive as well as the floppy.