Вы находитесь на странице: 1из 3

CH01 Basic Unix Commands ====================================================

=============================================================================
"cd [DIRECTORY]" Change the current directory to the one listed. Use "cd .." To
go up one directory.
"clear" Clears the screen of the terminal.
"ls" Lists the contents of a directory. Add "-i" for inodes, "-a" for all files,
"-l" for the long list format, "-h" for Kil/Meg/Gig printouts.
"date" shows the date and time from the system clock.
"cal" Shows the current month calendar. Use "cal [YEAR / 2012]" to print out the
entire year.
"cat" Used to output a text files contents to the terminal.
" >> " Append that after a command to dump the output to a text file. For
instance say I run "cat [TEXT FILE] >> /root/dump1" that will dump the
contents of whatever comes out of cat into a text or binary file in the root
directory called dump1. Very useful for logs and stuff.
"| grep "PATTERN"" Takes a line from a file and prints it out when it matches th
e pattern. I can also just use regular grep on a file. "a" will treat binary fil
es like text files. "-d recurse" Will search through the files inside a director
y.
Add "-c" to count the number of matching lines in the file.
Add "-o" to print only the matching part of the pattern.
To dump grep output into a text file use "grep > [TEXT FILE]" trying now. That
works.
"history -c" Appears to clear the bash history.
"cut" Is some program useful with grep. I'm not good with it.
But cut can be used to output the pipe to a text file like this:
"cut -f1 > [text file]" as a very basic example.
"gpg" the encryption suite for Unix. I can encrypt the
file using "gpg -e [filename]" and give a passphrase. Not sure how secure it
is though. Decryption is "gpg -d --output [output_filename] [gpg file]" and
giving the correct passphrase. "-o" is a shortcut for the output.
"--cipher-algo AES256" looks good for me. List ciphers with "gpg --version".
Now gpg wants me to specify a user id to encrypt stuff when I use "-e".
Figured it out. Use "-c" instead of "-e" to encrypt without user id.
"du" Estimates file space usage. "-a" for all, "-L" dereference links, "-h" huma
n readable, "--max-depth=[NUMBER]" try 0, "-s" summary.
"df" Report file system disk space usage. Use "-h" for Kil Meg and Gig.
"dir" List directory contents. "-a" Shows all files. "-l" for long format, "-h"
for human readable, "-i" for inodes of each file.
"adduser" Adds a user to the system. See the manual file for this command.
"rm [FILENAME]" Simple file deletion.
"shred -u [FILENAME]" Use this to securely shred a file. "-z" adds zeros to hide

any proof of shredding. Add "-" for directories.


"mkdir [DIRECTORY]" Creates a directory with the name.
"mv [FILE] [DIRECTORY/NEW NAME]" Takes a file and moves it from one directory to
another. You can also use it to rename files by changing the directory to the f
ilename. You don't need to use "-r" when moving a directory.
"cp [FILE] [DESTINATION]" Copies a file from a directory into another.
"dmesg" Prints the kernel ring buffer. Whatever the fuck that is.
"lshw" Lists hardware. Use with |less because of all the info.
"acpi" Some kind of package that has to be installed using "apt-get install acpi
" but it shows the battery level from the command line.
"[CTRL KEY] + c" Quits a process or file.
"man [COMMAND]" Displays the manual file for a certain command. Quit the file wi
th "q".
"hexedit [FILENAME]" Open up a hex editor on a file. "F5" disables the color.
"unrar x [FILENAME]" Extracts files from a RAR archive.
"locate [PATTERN]" A simple and efficient way to search for files. Use "-c" to d
isplay a count not the filenames.
"find" Search for files in a directory. "-d" is for depth. "-name [PATTERN]" for
the file. "*[PATTERN]" for a dot at the beginning of the pattern. Pretty compli
cated shit.
"more" Is used for displaying stuff one page or line at a time. Use SPACE to mov
e by one page at a time and use the ENTER key to move line by line. This is grea
t for when the output doesn't fit on one screen.
"nano" Pretty basic text editor, nothing fancy. Use control keys for reading and
saving files.
"pico" Text editor just like nano.
"stat" Display file or filesystem status. "-f" is used for filesystems. "-L" is
used for file system status.
"info coreutils 'stat invocation'" Full documentation for the stat command.
"uname -a" Prints the kernel information.
"umount" Unmount a filesystem from a directory.
"ps" Shows a snapshot of processes currently running.
"top" is more of a task manager for processes.
"mount" Mount a filesystem to a directory. Usually plugging in a flash drive pri
nts a message in the "dmesg" command. You can find the device listed in "/dev/"
and there is usually a 1 attached on the end. Mount the device to a folder usual
ly in the home directory. I think you have to be root to mount though. "mount /d
ev/sdb1 /root/FD_MOUNT_DIR" Also, "mount -l" pretty much shows what is currently

mounted on the filesystem. Use "ls /dev |grep sd" to show basic connections.
"mount -t vfat [DEVICE] [MOUNT_POINT]" Mounts the floppy drive that I use.
"updatedb" I guess it updates the index file for the locate function.
"sqlite" Opens up an SQLite editor. It's not the latest version though.
"sqlite3 [database]" Opens up an SQLite editor, its version 3.5.9 I think.
"vdir" Lists directory contents. Add "-a" for all files. Add "-d" for directory
entries instead of contents. "-g" long form ("-l") but without showing owner. "h" for human readable.
"info coreutils 'vdir invocation'"
"gdbm" The GNU database manager. Has dbm and ndbm compatibility. Open files with
"[FILE] [READER/WRITER] dbm" Looks like an SQL type thing.
"gdb" is the GNU Debugger. I guess it debugs executables.
"bc" Looks like some kind of weird calculator program. Pretty technical too. Use
"quit" to exit the shell prompt for bc.
"gzip" Compress or uncompress files. "gzip -d [FILENAME]" to bring the file back
. It's better to use tar for multiple files.
"tar" Used to extract files or create tar archives. "tar -cf [NEWTARARCHIVE.tar]
[FILE1] [FILE2]" creates one. To list use "tar -tvf [TAR]". Extract with x.
"tar -xvz" Will extract most gzipped files.
"tar -xvjf [FILENAME]" To extract bz2 files use.
"ssh" Open an SSH client.

Вам также может понравиться