GNU and Unix Commands Flashcards
make
Utility to read a source configuration file and maintain a group of files or programs
env
Shows the current session environment variables
pwd
Print the path of the current working directory
uname
Prints system information
uname -n
Node name
uname -s
Kernel name
uname -v
Kernel version
uname -r
Kernel release
uname -m
Machine/CPU info
uname -p
Processor info
uname -i
Hardware info
uname -o
Operating system name
uname -a
Print all info
export
Used to set an environment variable
export HOME = /home/user
unset
Used to remove an environment variable
unset $HOME
man (1)
Executable programs or shell commands
man (2)
System calls
man (3)
Library calls
man (4)
Special files (usally found in /dev)
man (5)
File formats and conventions
man (6)
Games
man (7)
Miscellaneous
man (8)
System administration commands
man (9)
Kernel routines
fmt
Reformats streams or files for display as indicated
join -t :
Will join lines on occurrences of :
join -1 FIELD
or
join -2 FIELD
Will join on the field in file 1 or in file 2
pr
Convert files for printing
split -l 2 file.txt name
Will split file.txt 2 lines at a time and name the output files namea, nameb, namec…
unexpand
Converts spaces to tabs
expand
Converts tabs to spaces
cut -f1 -d: myfile
Will return the first field of each line in myfile, as separated by colons. For example, if a line is “Matt:Miller:Man”, then “Matt” would be returned.
cut -c2 test.txt
Will display only those letters in the 2nd column of test.txt
cut -c3-6 test.txt
Will display the 3rd through 6th characters of each line
head -c 10 file.txt
Output the first 10 bytes of file.txt
head -n 10 file.txt
Output the first 10 lines of file.txt
nl
Add line numbers to a file for display or redirect to another file
sed ‘s/parttime/fulltime/’ myfile
Will replace the first occurrence of “parttime” in each line of myfile with “fulltime” (Not in the file, just the stream!)
sed ‘s/parttime/fulltime/w promotions.txt’ myfile
Will replace the first occurrence of “parttime” in each line of myfile with “fulltime” and write it to the file promotions.txt
sed ‘/fulltime/w fulltime.txt’ myfile
Will not replace anything, but will write all lines with “fulltime” in them to fulltime.txt
sed ‘s/]*>//’ myfile
Will substitute anything that starts with “”, and ends with “>”
tail -c 10 file.txt
Will output the last 10 bytes of file.txt
tail -n 10 file.txt
Will output the last 10 lines of file.txt
uniq -d
Only print duplicate lines
uniq -u
Only print unique lines
uniq
Prints all lines of a file, but merges duplicates to the first occurrence
od
Dump files in octal format
paste
Merge lines of files
sort file.txt
Outputs the contents of file.txt in alphanumerical order
tr
Translate/squeeze/delete characters from standard input writing to output
wc -l file.txt
Shows number of lines in file.txt
wc -c file.txt
Shows number of bytes in file.txt
wc -m file.txt
Shows number of characters in file.txt
wc -w file.txt
Shows number of words in file.txt
cp -a file1 file2
Makes an archive of file1 called file2
cp -r mydir mynewdir
Will copy the contents of mydir to mynewdir
cp -u
Copy only when the SOURCE file is newer than the destination file or when the destination file is missing
cp –backup
Will backup each destination file
cp -d
Will preserve links
mv file1 file2
Will rename file1 to file2
mv -f
Will not prompt to overwrite
mv -i
Interactive, prompt for overwrite
mv -n
No clobber, do not overwrite existing files
touch -a
Updates the access time only
touch -c
Do not create file if it doesn’t exist
touch -d
Parse string and use it instead of current time
touch -m
Change only the modification time
touch -r file1 file2
Makes file2’s access and modify times the same as file1’s
touch -t
Use specified timestamp
dd if=/dev/zero of=file.iso bs=1024 count=1
Reading from /dev/zero (which just contains zeroes) we want to write to file.iso 1024 bytes (1KB) one time.