Utilities Flashcards
ls -l
Lists the names of files
cat [filename]
Displays a text file
rm [-if] [filename]
Deletes a file
i prompts you for removal
f forces removal
hostname
Displays the system name
cp [source file] [destination file]
copies a file
mkdir [directory name]
Creates a new directory
rmdir [directory name]
Deletes a directory
rm *
Deletes everything in current directory
cd or cd ~
Takes user to home directory
mv [existing file name] [new filename]
Changes the name of a file; can also move files to a different directory
lpr -P [printer name] [filename(s)]
Prints file to certain printer
grep
Searches for a string
head [-number] [filename]
Displays the first number lines of file
tail [-f] [filename]
Monitors lines as they are added to the end of the growing file filename
tail displays end of a file
sort [filename[
Displays a file in order
uniq [filename]
Removes duplicate lines from a file
diff -u [file1] [file2]
Compares two files by breaking long, multiline text into hunks
file [filename]
Identifies contents of files
ln -s [directory 1] [directory 2]
Creates a symbolic link
|
Known as pipeline
Takes the standard output of one process and sends that output as the input of the second process
wc -w [filename or directory]
Displays the number of words in a file or number of files in directory
echo ‘String’ > [filename]
echo displays text
> means redirection
date
Displays time and date
script
Records shell session
Usually save session in file named typescript
!/bin/sh
This should always start in the first column in the first row of a shell file (i.e. at the very beginning of the file)
unix2dos
Converts Linux files to Windows and Mac OS X format
dos2unix
Converts Windows files to Linux files
dos2mac
Converts Mac OS X files to Linux files
bzip2 -v [filename]
Compresses a file, file is renamed with a .bz2 extension
- v causes bzip2 to report how much it was able to redce the size of the file
- k keeps the original file
Can compress tar files; usually have .tar.bz2 extension
bunzip2
Restores a file that has been compressed with bzip2
bzcat
Displays a file that has been compressed with bzip2
gzip
Compresses a file; less efficient than bzip2 and files are marked with .gz extension
Can compress tar files as well; usually have .tar.gz extension
tar -ctxvf [tar file] [filename(s)]
Packs and unpacks archives
Creates a single file called a tar file from multiple files or directory hierarchies and to extract files from a tar file
- c create -v verbose -f write to and read from file
- t displays table of contents -x extracts files from tar archive
which, whereis
Locates utilities
whereis uses standard locations instead of your search path to find a binary file, manual pages, source code
which uses search path
locate [filename]
Searches for files on the local system
who
Lists users on the system, terminal line identification, last login date and time
finger
Lists users on the system, location user logged in from, full name of user, user supplied vanity information
uptime
Displays system load and duration information
w
Lists users on the system
Also displays last command executed, system uptime and load average, CPU time used, login time (for day-old logins)
chmod -R [permission] [directory or filename]
Assigns permissions to directory or file
free
Displays memory usage information
write [receiving user]
Sends a message to user
mesg [y or n]
Denies or accepts messages
touch
Creates empty file
vim
Edits files from another directory