This how-to describes various UNIX/LINUX commands. I have found these commands useful over the years.
Misc Commands
Command | Description |
---|---|
Command | Description |
ps -ef | List all running processes |
ps -efww | List all running processes and wrap to screen |
find . -name <filename> | Searches the file system for specified file. |
find . -name <filename> 2>/dev/null | Search for file and remove all errors from output |
find . |grep <search> | Search for a file |
<cmd> 2>/dev/null | Redirect error to dev null |
<cmd> | grep -v <string> | Output lines not containing string |
history | show command history |
!<##> | execute command # from history |
!<start of command> | execute command from history starting with. |
CTRL-R | Search command history |
lsof -P |grep LISTEN | Display ports that your machine is listening on. Uses lsof (list open files)mockser |
dd if=<file> of=<file> [ bs=# ] [ count=# ] | dd copies what is specified in the input file (if) to the output file (of). bs= is the block size (bytes) and count= is the number of blocks to copy. See man dd for more informations. |
tar x|c|t [ z | Z | j ] [ f <file> ] <tar_file> | tar is an archiver. You can use it to expand (x), create (c) or test (see the content, t) of tar archives. If f option is specified, it will tell which file is the input (for x and t) or the output (for c). There are ways to also use compression with options:
See man tar for more information. There are a lot of more options and very useful functions like destination directory when unarchiving or directory to include when creating (C), other ways of compression and the interactive mode (that allows to choose what should be unarchived). |
sudo parted <img> unit B print | Print out the partition information of the image ie. > sudo parted new.img unit B print Model: (file) Number Start End Size Type File system Flags |
sudo mount -o loop,offset=<offset_in_bytes> <img> <folder> Specify the filesystem type: -t <fsType>
| Mount a partition to a directory ie. sudo mount -o loop,offset=4194304 new.img p1 ie. sudo mount -t ext4 -o loop,offset=63963136 my_image.img p2 |
dd if=/dev/zero of=<image> bs=1M count=100 | Create a blank image file |
mkfs.ext3 | Make file system ext3 |
lsusb | list usb devices |
rsync -av <source> <dest> | Archive all files from one folder to another. |
Apt-get Commands
Command | Description |
---|---|
apt-get update | update apt-get info |
apt-get install <application> | install application |
apt-get remove -V <application> | remove application |
apt-cache policy <application> | show versions |
apt-get install -y -q docker-engine=1.11.1-0~trusty | Install a particular version of docker |