Chapter 4: Advanced Unix Commands Flashcards
To read a text file in your terminal window, use either
more or less
The more command displays the contents of the text file one terminal screen at a time. To advance the file, press the SPACEBAR (for the next screen) or the RETURN key (for the next line).
The less command does the same thing, but you must press Q to exit when you reach the end of the file. The less command also allows the user to scroll back through the text you have already seen using either the UP arrow or the B key. The less command will also allow you to search the text.
eos% more filename.txt
eos% less filename.txt
can be used to compress multiple files into one, to minimize the size of a single file, or to recursively compress a directory
zip
eos% zip zipfile uncompressedfile
eos% zip zipfile uncompressedfile1 uncompressedfile2 …
-r is required for zipping up directories
eos% zip –r zipfile directory
You can decompress the file using the unzip command:
eos% unzip zipfile
Unzip decompresses the zip file and places the files into your current directory. You will have at least two files in your directory after unzipping – the uncompressed file and the .zip file.
TO see how much of your disk space you are using, and how much is free, you can use the ____ command
quota
eos% quot
allow you to attach pathnames to the “/ncsu” directory.
They also don’t have man pages
add/attach
attach
The attach command lets you connect a locker or a directory to the “/ncsu” directory so that you can cd to that location by typing cd /ncsu/lockername or cd /ncsu/directoryname instead of its full path. This is only in effect for the current terminal session.
eos% attach locationname
Note: locationname is the name of the locker or the directory that you are attaching
add
The add command will add a program shortcut to your terminal, but will not execute the program. After adding the program, you will be able to run it by inputting its name as you would a command. To determine the available programs, simply execute the add command to retrieve a list. This is only in effect for the current terminal session.
eos% add
to determine available programs
eos% add programname
to create a “shortcut”
Example:
To add, then execute, pico, a notepad/text editor that can be run in the terminal window:
eos% add pico
eos% pico
allows you to inspect and modify the access rights of your AFS space
fs
fs la
The “fs la” command allows you to list the access rights that are currently assigned in a particular directory.
To see the access information in your current working directory:
eos% fs la
To see access in a different directory:
eos% fs la pathname
allows you to modify the access settings of a particular directory. This command requires you to specify a pathname for the access, the unityid of the person you are granting access too, and the type of access.
fs sa
eos% fs sa pathname unityid access
l – look access only allows users to see the files that are in the directory r – read access allows users to read, view, or copy file contents, users must also have look access for this to work i – insert access allows users to move files or create new ones d – delete access allows users to remove files w – write access allows users to write files, and requires read, look, and insert access as well k – lock access allows users to lock others out of a directory. Do not lock yourself out of your own space. a – admin access gives users admin rights to your directory. They will be able to assign access for others to that directory. all – all access grants users l, r, i, d, w, k, and a access none – removes all accesses assigned to the user
What command tells you where your backups are located?
eos% quota
How to gain access to your backups?
eos% fs mkm BACKUP users.jschmoe.backup
This should have created a BACKUP directory - in this directory you will find a copy of what your home directory looked like around midnight the previous evening. You cannot write into the BACKUP directory, but you can copy the files you need out of it.
To un-mount the BACKUP directory, which will free up space you will need later, return to your home directory and type:
eos% fs rmm BACKUP