Laboratorium Komputerowe Progmar
Marcin Załęczny

We are using cookies in the page. If you use the page you agree for the cookies.      Close

Applications

partimage - application for creating disk images
gparted - application for partitioning and formatting disks
mkisofs - application for creating iso images ready to burn onto CD/DVD
cdrecord - application for burning iso images onto CD/DVD
dmesg - displays set of usefull system informations, it helps to know what system file is associated to pendrive plugged into the computer (ex. /dev/sdf1)
evince - pdf viewer
cabextract - application for extracting *.cab windows archives (located in the universe repo)
update-rc.d - command for installing/uninstalling system initialisation scripts (the scripts are runned during system startup)
rsyslog - replacement for a tradtional syslog daemon on Linux
apropos - command for displaying all commands related to passed as argument keyword
cfdisk - replacement for fdisk
xrandr - monitor management system command
Transmission - torrent client for Linux
eog - Gnome image viewer (Eye of Gnome)
xsane - scanning application (sudo apt-get install xsane)
comix - *.cbr comix viewer (sudo apt-get install comix, requires unrar program)
mysql-workbench- gui for managing MySQL databases (sudo apt-get install mysql-workbench)
SQLite DB Browser- gui for managing SQLite databases (sudo apt-get install sqlitebrowser)
SimpleScreenRecorder- program for recording screencasts
Ardour- complex music editor
VeraCrypt- program for encryption/decryption large data sets
TruPax- program for encryption/decryption small data sets (compatible with VeraCrypt)
gLabels- provides serial creating and printing invitations and visiting-cards
Lyx- gui for LaTeX documents edition
Lightworks- video editor
Brasero- application for copying/burning CDs and DVDs
fbreader- *.epub ebooks reader
photorec- program for scanning block devices (also damaged) and restoring removed files (or not accessible in standard way on damaged disk). Mounting the device is not required (program is part of testdisk package: sudo apt install testdisk)
sleuthkit- program for analysing disk drives (sudo apt install sleuthkit), commands available in this package:
  • img_stat /dev/sdc
  • mmls /dev/sdc - returns among others start_partition_offset for all existing partitions
  • fsstat -o start_partition_offset /dev/sdc
  • fls -o start_partition_offset /dev/sdc - lists all files in the root directory
  • fls -o start_partition_offset /dev/sdc directory_number - lists all files in a directory with specified number (the number we can obtain using command above)
  • fls -r -o start_partition_offset /dev/sdc - lists all files on specified partition (start_partition_offset) and files in all its subdirectories
ddrescue (from gddrescue package)- dumps all block device's content to a file (sudo apt install gddrescue)
foremost- restores files from block device or from its image (sudo install foremost)

Commands

Ripping from fname.mp4 file one frame starting at offset 148.9 and saving it to file on disk: frame.png ffmpeg -vframes 1 -ss 148.9 -i fname.mp4 -f image2 frame.png

Mounting remote filesystem: sshfs user@192.168.1.50:/remote-directory /mnt/local/directory -p 22

Downloading remote http file at maximum speed of 70kB using trickle command trickle -u 1 -d 70 wget -c http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.20.3.tar.bz2

Downloading remote ftp file using wget command (if file is partially saved then downloading is continued at file size offset): wget -c ftp://username:password@host_address/path/to/file

Downloading file with timestamping given: wget --timeout=120 --timestamping http://server/file

Downloading file and saving it with different file name: wget -O taglist.zip http://www.vim.org/scripts/download_script.php?src_id=7701

Limiting download speed using wget: wget --limit-rate=200k http://www.openss7.org/repos/tarballs/strx25-0.9.2.1.tar.bz2

Downloading in background (standard output of the command will be saved to `wget-log' file on disk): wget -b http://www.openss7.org/repos/tarballs/strx25-0.9.2.1.tar.bz2 Progress view: tail -f wget-log

Downloading file with custom user-agent specified: wget --user-agent="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.3) Gecko/2008092416 Firefox/3.0.3" URL-TO-DOWNLOAD

Downloading file with custom user-agent and referer specified: wget --referer="https://www.webpage.com" --user-agent="Mozilla/5.0" https://www.webpage.com/full/best.jpg

Checking remote file existence: wget --spider DOWNLOAD-URL

Specifying download tries count: wget --tries=75 DOWNLOAD-URL

Downloading all urls placed in text file (one url per line): wget -i download-file-list.txt

Downloading entire website WEBSITE-URL to LOCAL-DIR directory (mirroring it). All hyperlinks are translated in the way the downloaded website is displayed in webbrowser properly: wget --mirror -p --convert-links -P LOCAL-DIR WEBSITE-URL

Skipping pointed files during downloading: wget --reject=gif WEBSITE-URL

Redirecting standard errors from stderr to download.log file on disk: wget -o download.log DOWNLOAD-URL

Downloading file to maximum size of 5MB: wget -Q5m -i DOWNLOAD-URL

Downloading only specified types of files: wget -r -A.pdf DOWNLOAD-URL

Displays directory size following symbolic links: du -h -L

Displays the size of specified directory including its subdirectories (no deeper recurency involved): du -h -c --max-depth=1

Running shell with root privileges and global environment settings: sudo -i

Adding a user to the system. It's homedir is /var/www_tests, it's shell is /bin/bash and it belongs to www system group: useradd -c "www" -d /var/www_tests -m -s /bin/bash www

Adding existing user to existing group: usermod -a -G groupname username

Enter edition mode of file containing users which can gain root privileges (sudoers): sudo visudo

Changes www user's shell: chsh www

Removes \r characters inside the file file.txt: sed -i 's/\r//' file.txt

Displays second word of the dot-separated words (tty2 here): echo "5105.tty2.MyComputer" | awk 'BEGIN { FS = "." }; {print $2}'

Extracts second word of the dot-separated words (tty2 here) and then removes tty string of it (result is: 2): echo "5105.tty2.MyComputer" | awk 'BEGIN { FS = "." }; {print $2}' | sed 's/tty//'

Displays 2 by using regular expressions: echo "5105.tty2.MyComputer" | sed -e 's/.*y\(.*\?\)\..*/\1/'

Waits for entering the line and if it contains some string then it is displayed: awk '/me/{print "line containing me --", $0}'

Displays string length in bytes (here is 6 because of default Ubuntu's system encoding: UTF-8): awk 'BEGIN { print length("ąćę");exit }'

Displays substring starting at second byte (not at second letter!): awk 'BEGIN { print substr("ąćę",2);exit }'

Displays first word: echo "asd dfg hjk" | awk '{print $1}'

Displays third word (separator is set to : character): echo "asd:dfg:hjk" | awk -F: '{print $3}'

Print users that have bash as shell and home in /home directory: getent passwd | awk -F: '$7 ~ /\/bin\/bash/ && $6 ~ /^\/home/ {print $1}'

Scale image file to 50% its original size: convert src.jpg =resize 50% dst.jpg
mogrify -resize 400 src.jpg - better quality of scaled image

Appends specified images image#.png into one output image output_image.png. Appends them vertically: convert -append image1.png image2.png image3.png image4.png output_image.png

Appends specified images image#.png into one output image output_image.png. Appends them horizontally: convert +append image1.png image2.png image3.png image4.png output_image.png

Copy file /home/username/src_filename to /home/username/dst_dir directory and if it is a symbolic link then symbolic link is copied instead of copying pointed destination: cp -P /home/username/src_filename /home/username/dst_dir

Prints date encoded in unix timestamp: date --utc -d '@1197089792'

Re-compress *.png files using the largest possible compression ratio. The files are re-co Rekompresja plików png z największym współczynnikiem kompresji. Pliki są rekompresowane w miejscu. Jeśli wyjściowy plik wychodzi większy, to plik jest zostawiany bez zmian: advpng -z -4 *.png

Prints hard-disks by uuid: ls -l /dev/disk/by-uuid

Find file in / directory: find / -name filename.txt

Making iso image (image.iso) that contains file filename or entire dirname directory: mkisofs -r -R -J -l filename_or_dirname >image.iso

Burn image.iso image onto the CD (on second burning-device, first one is - scd0): cdrecord dev=/dev/scd1 -v --eject speed=4 image.iso

Copying CD/DVD into the second CD/DVD: mount -t iso9660 -o ro /dev/cdrom /mnt/cdrom
mkisofs -r -R -J -l -o /tmp/image.iso /mnt/cdrom
cdrecord dev=/dev/scd1 -v --eject speed=4 /tmp/image.iso

Mounting image.iso image into the /mnt/image directory: mount -t iso9660 -o loop image.iso /mnt/image

Mounting cdrom drive: mount -t iso9660 /dev/cdrom /media/cdrom

Unmounting and ejecting cdrom: umount /dev/cdrom
eject

Obfuscate hard disk with randomed values (it goes on by a few hours): dd if=/dev/urandom of=/dev/sda

Creating file test.zero of 1GB size and fulfilled with NULLs: dd if=/dev/zero of=test.zero bs=1024M count=1

Making ext4 filesystem on the disk: mkfs.ext4 -j -O extent -L "" /dev/sda7

Making fat32 filesystem on the sdcard: sudo mkfs.fat /dev/mmcblk0 -s 16 -F 32

Compress test.zero file with maximal ratio using gzip command and recording time of the process: /usr/bin/time -f “%U seconds CPU %P” gzip -c9 test.zero > test.gz Warning! It must be /usr/bin/time or internal time shell's command will be applied.

Compress test.zero file with maximal ratio using bzip2 command and recording time of the process: /usr/bin/time -f “%U seconds CPU %P” bzip2 -c9 test.zero > test.bz2 Compression with bzip2 takes about 2 times longer than by using gzip.

Compress test.zero file with maximal ratio using lzma command and recording time of the process: /usr/bin/time -f “%U seconds CPU %P” lzma -c9 test.zero > test.lzma Kompresja lzma zajmuję baaardzo długo. Lepiej sobie odpuścić. Compression with lzma takes as many hours that give up is recommended.

Compress directory with zip command: zip -r filename.zip dirname

Adding into zip archive specified files: zip -u filename.zip file1 file2 file3 ...

Uncompressing specified tar bz2 file: tar xjvf filename.tar.bz2

Uncompressing specified tar gzip file: tar xzvf filename.tar.gz

Uncompressing specified gzip file: zcat filename.gz > filename

Uncompressing specified tar xz file: tar xJvf filename.tar.xz

List of files of filename.tar.bz2 archive: tar tjvf filename.tar.bz2

List of files of filename.tar.gz archive: tar tzvf filename.tar.gz

Uncompress specified tar gzip file starting from specified file inside the archive: tar xzvf filename.tar.gz -K --starting-file backup/folder/fname.zip

Extract archive to a specified directory: tar -xvf ../eudev-2.1.1-manpages.tar.bz2 -C /usr/share

Prints full information about test* files inside current directory by using ls command. -h switch make the file sizez to be printed using human postfixes (KB, MB, GB, etc): ls -lh test*

Tar specified directory into opt.tar file: tar -cf opt.tar /opt

Compilation and installation of typical Linux library's sources:

 cd libname
    ./configure (by default prefix=/usr/local)
    make
    sudo make install (install it to the prefix directory, here: /usr/local)
    sudo ldconfig
       Now we must add /usr/local/lib directory into the /etc/ld.so.conf file (or one of included files)
       as first entry. Doing so we override already existing but older library of the same name.
       The new library will be used by ./configure scripts. After the edition we have execute following
       command:
       sudo ldconfig

Removing wpasupplicant package: dpkg --purge wpasupplicant
or
apt-get remove wpasupplicant

Install wpasupplicant package: apt-get install wpasupplicant

Displays short information about all installed net interfaces: ip link show
ip link list

Displays little more (among ip addresses are included) information about all installed net interfaces: ip addr show

Making specified net device to have specified ip address with mask (ip: 192.168.8.100 and 24bit mask: 255.255.255.0): ip addr add 192.168.8.100/24 dev eth0

Turn on/Turn off eth0 net interface: ip link set dev eth0 up/down

Displays routing table: ip route
or
ip route list

Adding default routing entry: ip route add default via 192.168.8.1

Scanning the air for available Access Points: iwlist wlan0 scan

Display some information about wlan0 device: iwconfig wlan0

Lists all devices installed in ndiswrapper: ndiswrapper -l

Removing specified driver from ndiswrapper: ndiswrapper -r drivername

Install specified driver in ndiswrapper: ndiswrapper -i drivername.inf

Save configuration accessible for modprobe: ndiswrapper -m

Adding a new job, that will run for a 5 minutes: at now + 5 minutes[ENTER]
warning: commands will be executed using /bin/sh
touch test [ENTER]
[press CTRL+D]
job 3 at Tue Jul 26 13:13:00 2011

List actual jobs to be executed: at -l or: atq

Run job at specified time: at 13:40 2011-08-05

Remove job that has specified number: atrm job_number

Install package: apt-get install package_name

Removes all cached packages: apt-get clean

Lists all (also available for installation) packages: apt-cache pkgnames

Displays information about installed package: apt-cache show package_name

Removes package together with its configuration files: apt-get --purge remove package_name

dpkg -l - compact list of installed packages including short description
dpkg -s package_name - information about package's status including short package description
dpkg -p package_name - information about package's status including short package description (the same as above)
dpkg -L package_name - displays package's file list
dpkg -S pattern - searches for packages that include file name matching specified pattern
dpkg -l | cut -f 3 -d" " - displays list of installed packages
dpkg -r package - removes package

Prints installed glibc = libc = Gnu standard c library version: dpkg -l | grep libc6

Prints installed libstdc = Gnu standard c++ library version: dpkg -l | grep libstdc

Extracting control files from specified package: dpkg -e package_name

Displays extended information about specified package (ex. list of other required packages and theirs versions): dpkg -I package_name

Displays version number of currently installed package (specified without version number and architecture): dpkg-query -W basic_package_name for instance: dpkg-query -W zip

Displays previous and current runlevel: runlevel

CAUTION: description below is valid for Ubuntu version 14.10 and below. For version 15.04 and above read this article. Installs some_script.sh placed in /etc/init.d directory as a script that is executed at system startup (autostart). It is executed in default runlevels: 2,3,4 and 5. It is not executed in runlevels: 0, 1 and 6. update-rc.d some_script.sh defaults Removes script's startup links. -f switch forces removing the links event if script exists in /etc/init.d directory: update-rc.d -f testscript.sh remove

Detail information about installed hardware: lshw Detail information about installed hard drives: lshw -C disk Detail information about installed net devices: lshw -C network

Lists only directories in current location: ls -l | grep "^d"

Searching with Perl regexp's and show only match: grep -o -P "\.\w([\w\d]*)" mootools-1.3.2-core.js

Running system upgrade with redirecting stderr to stdout and redirecting stdout both to monitor and file named apt-get.log. Tee command displays data to the monitor and transparently saves it to the file on disk although: apt-get upgrade 2>&1 | tee ~/apt-get.log

Run gedit program as root (Alt+F2) with opened /etc/network/interfaces file: gksudo gedit /etc/network/interfaces

Command for sending error report with some detailed information to Ubuntu system maintainers (working not tested): reportbug --template -S normal package-name

Makes jar file: jar cf file.jar input-files

Displays jar file content: jar tf file.jar

Extracts jar file: jar xf file.jar

Extracts specified files from the jar file: jar xf file.jar archived-file(s)

Embedding jar applet inside the web page:


    <applet code=AppletClassName.class
        archive="JarFileName.jar"
        width=width height=height>
    </applet>
                

Executing jar application: java -jar app.jar

Signing jar file with certificate: jarsigner -keystore .keystore -storepass password myjar.jar alias

Using mysql to display numbers 1 22 333 444 separated with colons: mysql -u root -p -BNe "SELECT '1', '22', '333', '4444'" | tr \\t ','

Importing sql commands into current Mysql database: \. /var/www/sql/sample_db.sql

Removes last character from variable in bash: variable=${variable:0:$((${#variable}-1))}

Set value of 1 to variable contained in b variable: eval $b=1

Bash. Prints value of variable with name stored in x variable. $[] is equivalent to $(( )): $[$x]

Using ssh to connect to remote host without checking RSA fingerprint: ssh -o StrictHostKeyChecking=no user@192.168.30.40

Recording all actions on the Pulpit: recordmydesktop --no-sound -o /tmp/aaa.ogv

Installing flashplayer for firefox: Download file: install_flash_player_10_linux.tar.gz from webpage: http://get.adobe.com/flashplayer
Extract file install_flash_player_10_linux.tar.gz and copy file libflashplayer.so to the directory: /usr/lib/firefox-addons/plugins

Application for listening socket: unix-listen:/tmp/socket and prints data into stdio: socat unix-listen:/tmp/socket stdio

Close system immediately from commandline: shutdown -h now

Reboot system from commandline: shutdown -r now or reboot

List devices with btrfs filesystem: btrfs device scan

List device types (device type) with btrfs filesystem: btrfs filesystem show [/dev/sdb]

Create btrfs filesystem: mkfs.btrfs /dev/sdb

Create btrfs filesystem paralelly on a few devices with mirroring (RAID1): mkfs.btrfs /dev/sdb /dev/sdc /dev/sdd

Create btrfs filesystem paralelly on a few devices without mirroring (RAID0): mkfs.btrfs -m raid0 /dev/sdb /dev/sdc /dev/sdd

Create btrfs filesystem paralelly on a few devices with mirroring metadata and file data (RAID10): mkfs.btrfs -m raid10 /dev/sdb /dev/sdc /dev/sdd

Mounting RAID: mount /dev/sdb /mnt/raid

Delete device from RAID: btrfs device delete /dev/sdd /mnt/raid

Add device to RAID: btrfs device add /dev/sdd /mnt/raid

Balancing RAID filesystem (after adding new hd): btrfs filesystem balance /mnt/raid

Adding subvolume: btrfs subvolume create /mnt/raid/subvol

List of existing subvolumes: btrfs subvolume list /mnt/raid

Set chosen subvolume as default one: btrfs subvolume set-default ID /mnt/raid

Mounting chosen subvol in other directory: mount -t btrfs -o subvol=subvol /dev/sdb /subvol

Making a snapshot: btrfs subvolume snapshot /mnt/raid /mnt/snapshot_of_root

Display subvolumes and their snapshots: btrfs subvolume list /mnt/raid

Deletes subvolume and snapshot: btrfs subvolume delete /mnt/raid/subvol
btrfs subvolume delete /mnt/raid/snapshot_of_root

Resize subvolume: btrfs filesystem resize -1GB /mnt/raid
btrfs filesystem resize +1GB /mnt/raid
btrfs filesystem resize max /mnt/raid

More detailed counterpart of df command for btrfs filesystem: btrfs filesystem df /mnt/raid

Volume's defragmentation: btrfs filesystem defragment /mnt/raid

Mounting of volume with CRC-32C turned off and zlib compession turned on: mount -t btrfs -o nodatasum,compress /dev/sdb /mnt/raid

Display which process opened given file: lsof /var/log/syslog

Display files opened by specified process: lsof -c rsyslog

Display local services that are listening for connections: lsof -iTCP | grep LISTEN

Display all outgoing ssh connections with server example.pl opened by user username: lsof -a -u username -i@example.pl:22

Tests availability of a webpage under stress of specified count of users: siege -c 30 http://www.webpage.com

Show information on memory and processor usage: vmstat

Show information on memory and processor usage in 5 lines with 1 second interval: vmstat 1 5

Show stats for disks usage: vmstat -d

Displays stats for CPU and memory events: vmstat -s

Display stats for specified partition: vmstat -p /dev/sdb1

Display stats for cpu usage and I/O operations: iostat

Display stats for cpu usage and I/O operations: dstat

Display running process count: dstat --proc-count

Display disk usage stats: dstat -d --disk-util --freespace

Display memory usage stats: dstat -g -l -m -s --top-mem

Display cpu usage stats: dstat -c -y -l --proc-count --top-cpu

Display networking usage stats: dstat -n --socket --tcp --udp

/var/log/messages file monitoring. If some lines are added to the file, the ones are displayed on the screen: tail -f /var/log/messages

Printing current date in YYYYmmdd format: date +%Y%m%d

Setting current hour: date +%T -s "13:48:50"

Renew ip address from dhcp server: dhclient -r

Recursive removing directory .svn from current directory and all its subdirectories: find . -type d -name .svn -exec rm -rf {} \;

Obtaining SHA1 fingerprint of android test certificate: keytool -list -alias androiddebugkey -keystore /home/mzaleczny/.android/debug.keystore -storepass android -keypass android

Obtaining all data of android test certificate: keytool -list -v -alias androiddebugkey -keystore /home/mzaleczny/.android/debug.keystore -storepass android -keypass android

Generating new certificate: keytool -genkey -v -keystore ~/.android/test.keystore -alias androiddebugkey -storepass android -keypass android -keyalg RSA -validity 14000

Displays kernel threads: ps -ef

Displays process list running in the system with their nice values (in NI column): ps -el

Displays process list running in the system with their real time priority (in RTPRIO column). Value of '-' in RTPRIO column means lack of real time priority: ps -eo state,uid,pid,ppid,rtprio,time,comm

Less compiler can be instaled by following command: sudo apt-get install node-less

Print hexadecimal file content together with its offsets on the left: od -Ax -tx1 -w16 <fname

Removing debugging symbols from the files: strip --strip-debug /tools/lib/*
strip --strip-unneeded /tools/{,s}bin/*
CAUTION: --strip-unneeded command shouldn't be runned for libraries because the static ones would be corrupted.


uname -a                           # Get the kernel version
lsb_release -a                     # Full release info of any LSB distribution
cat /etc/debian_version            # Get Debian version
uptime                             # Show how long the system has been running + load
hostname                           # system's host name
hostname -i                        # Display the IP address of the host
man hier                           # Description of the file system hierarchy
last reboot                        # Show system reboot history
dmesg                              # Detected hardware and boot messages
lsdev                              # information about installed hardware (requires procinfo package)
sudo dd if=/dev/mem bs=1k skip=768 count=256 2>/dev/null | strings -n 8 # Read BIOS
cat /proc/cpuinfo                  # CPU model
cat /proc/meminfo                  # Hardware memory
grep MemTotal /proc/meminfo        # Display the physical memory
watch -n1 'cat /proc/interrupts'   # Watch changeable interrupts continuously
free -m                            # Used and free memory (-m for MB)
cat /proc/devices                  # Configured devices
lspci -tv                          # Show PCI devices
lsusb -tv                          # Show USB devices
lshal                              # Show a list of all devices with their properties (requires hal package)
sudo dmidecode                     # Show DMI/SMBIOS: hw info from the BIOS


gconf-editor - configuration editor
md5sum - calculating md5 control sum of specified filename or standard input
sha1sum - calculating sha1 control sum of specified filename or standard input
partprobe /dev/sda - Informs operating system about changes in
           partition table of sda drive
mount -o remount, rw / - Remounting / filesystem with read/write privileges
env - lists user environment variables
set = declare - lists all environment variables
help - displays internal bash commands
help cmd - displays help for specified command
type cmd - displays location of specified command
history - displays bash history
tail -f filename - displays last 10 lines of the file and waits for and
           displays next lines saved to the file
sudo fdisk -l - displays partition information for all drives in the system
mount - displays all mounted filesystems
lsof - displays opened files list
fuser - displays information about which processes owns opened files
tune2fs -c - sets max counter of specified drive mountings which after
           exceeding causes running disk checker tool
tune2fs -i - sets max counter of specified drive mountings days which
           after exceeding causes running disk checker tool
tune2fs -l /dev/sda - displays hard drive information
tune2fs -j /dev/sda - converts ext2 filesystem to ext3 filesystsems
           (adds journal)
tune2fs -O extents,uninit_bg,dir_index /dev/sdb1 - converts ext3 filesystem
           to ext4 filesystem
find /home/mzaleczny -xdev -user mzaleczny -print | xargs ls -ldS >output.txt -
           lists all files of mzaleczny user within his home directory sorted descending
           (for files with spaces in name there are displayed errors)
find /home/mzaleczny -xdev -size +700k -print | xargs ls -ldS >output.txt -
           lists all files greater than 700 kb of mzaleczny user within his home directory
           sorted descending (for files with spaces in name there are displayed errors)
lspci -vv | grep -i eth - displays detailed information about network
           interface card
wget -p http://strona.pl - downloads entire page with css styles
           and scripts
wget -pk http://strona.pl - downloads entire page with css styles and
           scripts and converts hyperlinks to point local files
curl -T install.log ftp://user:haslo@ftp.przyklad.com
           -Q "-RNFR install.log" -Q "-RNTO Xinstall.log"
           - uploading file install.log to ftp server and renaming it to Xinstall.log
scp plik user@serwer:/tmp/ - copies file by ssh to /tmp directory on remote
           server
scp user@serwer:/tmp/plik . - copies file by ssh from remote server to current
           working directory
scp -r katalog user@serwer:/tmp/ - copies recursively entire directory by ssh
           to remote server
scp -P 12345 plik user@serwer:/tmp/ - copies file by ssh to /tmp directory on
           remote server connecting with ssh on remote server on 12345 port
rsync --recursive --verbose --dry-run directory/ user@serwer:/tmp/ - displays information about
           what files and directories will be copied (by ssh) to the remote directory /tmp on specified server
rsync --recursive --verbose directory/ user@serwer:/tmp/ - copies recursively entire local directory by ssh
           to remote server to dir /tmp
rsync --recursive --verbose user@serwer:/tmp/ directory/ - copies recursively entire content of the
           remote directory /tmp by ssh to current machine
findsmb - scans network for SMB servers
smbtree - displays tree of network neighbourhood
smbpasswd -a username - adds Linux user to Samba group
smbclient -L serwer - lists services served by specified server for
           anonymous user
smbclient -L serwer -U username - lists services served by specified server
           for specified user
smbclient //192.168.1.1/mojudzial -U username - connecting to Samba directory
mount -t cifs -o username=robert,password=haslo //192.168.1.1/mojudzial /mnt/punktmontowania -
           mounting samba directory within local filesystem
smbstatus - displays Samba connections and file locks
nmblookup nazwa - displays ip address of NetBIOS named machine
nmblookup -U 192.168.1.255 serwer - displays ip address of NetBIOS named
           machine within specified subnet
testparm - tests Samba config file
testparm filename - tests specified Samba config file
sudo fusermount -u /remote/directory - unmounting remote directory mounted
           earlier by sshfs command
ip link set eth1 promisc on - setting network card to promiscuous mode
usermod -d /home/username username - changes user's home directory for
           specified user
pwconv - converts file /etc/passwd containing hashed passwords to files /etc/passwd
           (without hashed passwords) and /etc/shadow (with hashed passwords)
grpconv - converts file /etc/group containing hashed passwords to files /etc/group
           (without hashed passwords) and /etc/gshadow (with hashed passwords)
netstat -tupn - lists TCP (-t) and UDP (-u) connections and process that owns the
           connection (-p) without translating IP addresses to human readable names
           (-n <=> --numeric)
killall -s SIGHUP inetd - sending SIGHUP signal to inetd process (it makes the process
           to reread configuration file)


ping -s 1472 server - pings given server with package of specified size (in bytes)
/etc/init.d/networking restart - restarts networking
find dirname -type d | xargs chmod 777 - sets privileges of 777 for all subdirectories of directory dirname
apache2ctl configtest - tests apache2 configuration file if it doesn't have errors
apache2ctl graceful - restart apache2 service
/etc/init.d/apache2 restart - restart apache2 service
gpasswd -a username groupname - adds user username to group groupname
lpr document.ps - sending specified document to the default printer
lpr -P printername document.ps - sending specified document to the printername printer
lpr -P printername document1 document2 document3 - sending document1, document2, doument3 files to the printername printer
lpc status - shows status of all installed printers
lpstat -p - displays available printers
lpstat -o or lpq - lists default printer's queue
lprm - - removes all printer jobs of currently logged user from default printer
lprm -P lp0 - removes all printer jobs from specified printer
lprm 133 - removes job with number 133 from default printer
fuser -v filename/dirname - lists processes which are using specified file or directory
fuser -k filename/dirname - kills processes which are using specified file or directory
cpio -idv < filename - extracting filename file (if is of cpio archive) to current working directory
initctl list - prints status of all available Upstart services
status service - prints status of specified Upstart service
stop service - stops specified Upstart service
start service - starts specified Upstart service
fsck -y -C /dev/sda1 - scans and fixes found errors in specified filesystem

Dumps database of name test and compress it to specified filename:
mysqldump -u root -p test | gzip -c9 >"/home/mzaleczny/backup/$date"_databases_test.sql.gz

List recursively all content of /tmp directory: ls -R /tmp

Remove recursively all files a and aa from /tmp directory: find /tmp \( -name a -o -name aa \) -delete

Formating date output we can do by specify its format after + sign, ex: date +"%A %B %d"

Command script allows us to grab all terminal session of current user until command exit: script -a output_file

Converts line endings from Linux format to Windows format: unix2dos plik.txt

Converts line endings from Linux format to Mac OS X format: unix2mac plik.txt

Converts line endings from Windows format to Linux format: dos2unix plik.txt

Converts line endings from Windows format to Mac OS X format: dos2mac plik.txt

List tar archive content without extracting its: tar -tf archive.tar

Display current shell name: echo $0

Less files we compile by executing: lessc bootstrap.less >bootstrap.css Lessc application can be installed by: sudo apt-get install node-less

Decreasing jpeg file size: jpegoptim --strip-all fname.jpg Jpegoptim application can be installed by: sudo apt-get install jpegoptim

Decreasing png file size: optipng -o5 fname.png Optipng application can be installed by: sudo apt-get install optipng

Decreasing size of all *jpg files in current directory and all its subdirectories: find . -type f -name "*.jpg" -exec jpegoptim --strip-all {} \;

Checking for GLIBC version: ldd --version | head -n1 | cut -d" " -f2-

Checking for kernel version: cat /proc/version

Checking for Perl version: echo Perl `perl -V:version`

Initializing /dev/sda8 partition as a swap partition: mkswap /dev/sda8

Turning on swap partition: /sbin/swapon -v /dev/sda8

Downloading to specified directory all URL addresses specified in wget-list file: wget --input-file=wget-list --continue --directory-prefix=~/sources Wget-list file should contain one URL per line, ex: http://ftp.gnu.org/gnu/bash/bash-4.3.30.tar.gz
http://alpha.gnu.org/gnu/bc/bc-1.06.95.tar.bz2
http://ftp.gnu.org/gnu/binutils/binutils-2.25.tar.bz2
ftp://ftp.astron.com/pub/file/file-5.22.tar.gz

Sprawdza sumy kontrolne plików podanych w pliku md5sums: Checks md5 control summs for files specified in md5sums file: md5sum -c md5sums Md5sums file should contain one md5 sum and a file per line, ex: a27b3ee9be83bd3ba448c0ff52b28447 bash-4.3.30.tar.gz
5126a721b73f97d715bb72c13c889035 bc-1.06.95.tar.bz2
d9f3303f802a5b6b0bb73a335ab89d66 binutils-2.25.tar.bz2
8fb13e5259fe447e02c4a37bc7225add file-5.22.tar.gz

Create lfs group: groupadd lfs

Create user lfs which: belongs to group lfs, has bash as a default shell and has home directory in /home/lfs (-m parameter, the directory is created if already not exists). Parameter -k /dev/null prevents creating default home directory content from /etc/skel directory: useradd -s /bin/bash -g lfs -m -k /dev/null lfs

Imports sql commands to current Mysql database: \. /var/www/cake/blog_tutorial/sql/blog_db.sql

Displays i-node number and the name of specified file: ls -i "file_name"

Searches current directory for all files with specified i-node number: find . -xdev -inum $inode -print -xdev parameter prevents searching other filesystems than the one in which current directory is.

To check spelling, first make sure that you have english dictionary for GNU Aspell installed: sudo apt-get install aspell-en and next execute: cat document.html | aspell list --mode=sgml Parameter --mode=sgml makes aspell to skip html tags.

Creates new file new_file.txt which consists of header.txt file, command's standard output and footer.txt file: command | cat header.txt - footer.txt > new_file.txt

Removes all privileges for group and others for a given file: chmod go= file

Crontab files for all users in Ubuntu are located in: /var/spool/cron/crontabs. Each of them have the same name as the user it belongs to.
Edit crontab file for current user: crontab -e Display crontab file for current user: crontab -l Remove crontab file for current user: crontab -r Edit crontab file for specified user (mzaleczny) - only root may do it: sudo crontab -u mzaleczny -e

Set the priority (nice value) equal to 4 for all processes of mzaleczny user: renice -n 4 -u mzaleczny Set the priority (nice value) equal to -4 for all processes of mzaleczny user (only root may do it): sudo renice -n -4 -u mzaleczny

Installs screen tool: sudo apt-get install screen Lists screen active sessions (in format: pid.tty.host): screen -ls Runs new screen session: screen bash
while (true); do echo "Tekst"; sleep 1; done
Detaches from current screen session. Programmes and commands that are running in the session stay running even after user's logout: CTRL+A d Attaches to specified screen session: screen -r pid or screen -r pid.tty.host

Displays short information about specified file's type: file filename Displays short information about specified compressed file's type: file -z filename

Lists content of a cpio archive: cpio -tv < archive_name

Extracts content of specified cpio archive (be careful with absolute paths stored in archive, because some files in the root filesystem can be replaced): cpio -i -d < archive_name

Extracts content of specified cpio archive. All absolute paths "/..." are replaced with relative ones "./...": cpio --no-absolute-filenames -i -d < archive_name

Extracts an ar archive: ar x archive_name.a

Lists content of specified deb archive: ar -t package_name.deb

Extracts a deb package into the current directory: ar -x package_name.deb

Let's assume that we have a directory named old with a project and a directory named new with the same project but extended with some changes. A patch file that transforms old directory content into the new one can be created by executing following command: diff -Nur old new > mypatch.diff Now, to transform old directory into a new one apply the patch file in following way: patch --dir old < mypatch.diff To withdraw the changes applied by the patch file and get old directory content from the new one - issue following command: patch --dir new -R < mypatch.diff

Compiles assembler source file to get output executable: gcc -o programme -nostdlib programme.S

Displays information about executing time (time that elapsed since application started), PID, priority, nice value and command name for two specified scripts (script1.sh i script2.sh) and for current shell (-p $$): ps -C script1.sh -C script2.sh -p $$ -o etime,pid,pri,ni,cmd

Changes nice value to 4 for process with pid eqauals to 1212: renice 4 -p 1212

Displays information about PID, state and command name for job of number %1: jobs -x ps -p %1 -o pid,state,cmd

Displays list of running in the background jobs: jobs -l

Converting gif file to a png one: giftopnm file.gif | pnmtopng > file.png

Sorts a specified file in an alphabetic order: sort file Sorts a specified file in an reversed alphabetic order: sort -r file If the rows of the file begins with the number then it sorts them in a numeric order: sort -n file

Searching the system manual for the specified keyword: man -k word

Displays current time in seconds since 1970-01-01 00:00:00: date +%s

Copies src directory to the remote machine with excluding .git subdirectories: rsync -a --exclude=.git src uzytkownik@komputer:

Copies src directory to the remote machine with limiting bandwidth to 1000kB/second: rsync --bwlimit=1000 -a src uzytkownik@komputer:

Executes console application (ex. apt-get update) with other then default language: LANG=pl_PL.UTF-8 LANGUAGE=pl_PL sudo apt-get update

Parallel application installation: sudo apt-get install moreutils Scale all pic*.png files found in the current directory to the 50% of theirs original size. All scaling operations are arranged evenly by the parallel application between all processor's cores: find . -maxdepth 1 -name "pic*.png" | parallel convert -scale 50% {} small/{}

Joins four pictures pic1.png, pic2.png, pic3.png, pic4.png (all of the same size) into one picture joined.png which consists of the two rows and two columns separated by the 2 pixels: montage pic1.png pic2.png pic3.png pic4.png -geometry +2+2 joined.png

Adds text to the picture: convert picture.jpg -gravity North -font /path/to/file/font.ttf -pointsize 100 -stroke "#123456" -strokewidth 5 -annotate 0 "Picture title" output_picture.jpg Allowed values for the gravity option can be listed by: convert -list gravity Available fonts can be listed by: convert -list font Right after the -annotate option we specify text rotation angle (in the example: 0) and the text oneself.

Creates a pdf file from the specified pictures: convert *.png pictures.pdf

Extracts pictures of the pdf file: convert pictures.pdf picture%04d.png

Places one picture onto the second one: composite -gravity SouthEast -dissolve 10% -geometry +20+20 pic_src.png pic_dst.png output_pic.png

Compares two pictures: compare pic1.png pic2.png differences.png

Displays picture's exif metadata: exiftool picture.jpg

Removes picture's exif metadata: exiftool -all= picture.jpg

Adds a text comment to the specified picture: exiftool -comment="Comment text" picture.jpg

Optimizes picture given: jpegtran -optimize pic.jpg >outpic.jpg

Rotates the picture by a 90 degrees: jpegtran -rotate 90 pic.jpg >outpic.jpg

Displays statistical data for the available pckages: apt-cache stats

Displays all available packages in the alphabetical order: apt-cache pkgnames

Displays details for the specified package (without the files that the package contains): apt-cache show package_name

Displays details for the specified package's source package: apt-cache showsrc package_name

Displays dependencies for the specified package: apt-cache depends package_name

Recursive search for the http/https address strings in files in the directory directory_name except the addresses that contain references to the android's schemas (schemas.android.com): grep -Eir "https?://" directory_name | grep -v "schemas.android.com"

Adds mzaleczny user to sudo group and therefore allow him to invoke sudo command: adduser mzaleczny sudo

Burns specified iso image on the pendrive: sudo umount /dev/sdX
sudo dd if=/path/to/ubuntu.iso of=/dev/sdX bs=4M && sync

Displays active disk operations scheduler: cat /sys/block/sda/queue/scheduler

Displays available for pkg-config libraries: pkg-config --list-all

Records audio wav file: arecord clip.wav

Measures data transfer on ppp0 interface (UMTS): vnstat -u -i ppp0

Displays current stats of data transfer on specified inteface: vnstat -i ppp0

How to obtain glib library version: cat /usr/lib/x86_64-linux-gnu/pkgconfig/glib-2.0.pc | grep Version

Downloads webpages specified in urls.txt file with random delay between each two downloads: wget --wait=10 --random-wait --input-file=urls.txt

Downloads recursive entire webpage with random delay between each two subpage downloads: wget --wait=10 --random-wait --mirror -p --convert-links -P SDL2 https://wiki.libsdl.org/

Apply a patch: patch <fname.patch

Withdraws a patch applied: patch -R <fname.patch

Obtains current OpenGL version: glxinfo | grep "OpenGL version"

Joins all *.png files of the same image size (128x128px) into one tilemap (the tiles are contiguous each other with n margins): montage *.png -geometry 128x128+0+0 tilemap.png

Searches for files of size greater than specified size in bytes: find . -type f -size +4096c

Searches for files of size lesser than specified size in bytes: find . -type f -size -4096c find -size n[cwbkMG]
   File uses n units of space. The following suffixes can be used:
   `b' for 512-byte blocks (this is the default if no suffix is used)
   `c' for bytes
   `w' for two-byte words
   `k' for Kilobytes (units of 1024 bytes)
   `M' for Megabytes (units of 1048576 bytes)
   `G' for Gigabytes (units of 1073741824 bytes)

Searching for files of specified type and date (year) of last access: find . -type f \( -name "*.php" -o -name "*.ctp" -o -name "*.html" -o -name "*.css" -o -name "*.js" \) -printf "%AY %p\n" | grep 2017

Turns on executing commands with root privileges on the phone (it must be rooted): adb root

Backups directory /data on smartphone with Android and stores it in the file android_data.tar.gz: adb exec-out "GZIP=-1 -czpf - /data 2>/dev/null>" > android_data.tar.gz

Restores data (created in above advice) to the phone with Android: adb exec-in "tar xzpf -" <android-data.tar.gz

Restores specified subdirectory inside /data directory (created above) to the phone with Android: adb exec-in "tar xzpf - data/selected/directory" <android-data.tar.gz

Sets specified screen resolution: xrandr -s 1366x768

Opens Ubuntu settings window: unity-control-center

Converts all png files in current directory to jpg format: mogrify -format jpg *.png

Turns on icons in application's menu: gsettings set org.gnome.desktop.interface menus-have-icons true

Turns on icons in application's buttons: gsettings set org.gnome.desktop.interface buttons-have-icons true

Dumps damaged drive (block device) into an image file: sudo ddrescue -r 3 /dev/sda /storage/rescue/image.dd /storage/rescue/image.logfile