Linux tiny Tips

(for myself…)

Transfer file to the destination pc:

option 1:

#scp mylocalfile.txt root@<destination_ip>:/recipient/directory/

option 2:

A simple option is to use netcat (nc). This is particularly useful on stripped down Linux systems where services like ssh and ftp are turned off.

On destination machine run the following command: nc -l -p 1234 > out.file

On source machine run the following command: nc -w 3 <dest-ip-adr> 1234 < out.file

For more details look, for example, here.

There are also netcat implementations for Windows, e.g. ncat.


How to Linux Terminal Split Screen With Screen:


#sudo apt-get install screen

How to split screen
a)Split the Window
Ctrl + a, Then Press Shift + s
Ctrl + a, Then Press Shift + \

b)Switch between spilted windows
Ctrl + a, Then Press Tab
Ctrl + a, Then Type :focus
* Here :focus is a command

c)In the spited window use following command to open existing session
Ctrl + a, Then Press 0-9
Ctrl + a, Then Press n or p
Ctrl + a, Then Press Shift + ‘
Ctrl + a, Then Presss c

d)Resize a splitted window/region
Ctrl + a, Then Type :resize 25
* Here :resize is a command

e)Remove current splitted window/region
Ctrl + a, Then Type :remove
* Here :remove is a command
Ctrl + a, Then Press Shift + x

f)Remove all spiltted windows/regions except the current one.
Ctrl + a, Then Type :only
* Here :only is a command
Ctrl + a, Then Press Shift +q

g) Close the screen and all regions
Ctrl + a, Then Press \

Screen Terminal Multiplexer Commands



VIM,eMacs, Sublime-text


Guake Terminal

Connection & File Transfer:

SecureCRT,  SSH, putty, FileZilla


Run Program in background and save the log to the file:

Redirect the output to a file like this:

./ > somefile 2>&1 &

This will redirect both stdout and stderr to the same file. If you want to redirect stdout and stderr to two different files use this:

./ > stdoutfile 2> stderrfile &



Task: List or display loaded modules

Open a terminal or login over the ssh session and type the following command
$ less /proc/modules
Sample outputs:

sha1_generic 1759 4 - Live 0xffffffffa059e000
arc4 1274 2 - Live 0xffffffffa0598000
ecb 1841 2 - Live 0xffffffffa0592000
ppp_mppe 5240 2 - Live 0xffffffffa058b000
ppp_async 6245 1 - Live 0xffffffffa0584000
crc_ccitt 1323 1 ppp_async, Live 0xffffffffa057e000
ppp_generic 19291 6 ppp_mppe,ppp_async, Live 0xffffffffa0572000
slhc 4003 1 ppp_generic, Live 0xffffffffa056c000
ext3 106854 1 - Live 0xffffffffa0546000
jbd 37349 1 ext3, Live 0xffffffffa0533000
sha256_generic 8692 2 - Live 0xffffffffa0525000
aes_x86_64 7340 2 - Live 0xffffffffa0517000
aes_generic 25714 1 aes_x86_64, Live 0xffffffffa050b000
ahci 32950 20 - Live 0xffffffffa007b000
libata 133824 3 ata_generic,pata_jmicron,ahci, Live 0xffffffffa0045000
scsi_mod 126901 3 usb_storage,sd_mod,libata, Live 0xffffffffa0012000
thermal 11674 0 - Live 0xffffffffa0009000
thermal_sys 11942 3 video,processor,thermal, Live 0xffffffffa0000000

To see nicely formatted output, type:
$ lsmod
Sample outputs:

Module                  Size  Used by
sha1_generic            1759  4
arc4                    1274  2
ecb                     1841  2
ppp_mppe                5240  2
ppp_async               6245  1
crc_ccitt               1323  1 ppp_async
ppp_generic            19291  6 ppp_mppe,ppp_async
slhc                    4003  1 ppp_generic

First column is Module name and second column is the size of the modules i..e the output format is module name, size, use count, list of referring modules.

Finding more info about any module or driver

Type the following command:
# modinfo driver-Name-Here
# modinfo thermal_sys
# modinfo e1000e

Sample outputs:

filename:       /lib/modules/2.6.32-5-amd64/kernel/drivers/net/e1000e/e1000e.ko
version:        1.2.20-k2
license:        GPL
description:    Intel(R) PRO/1000 Network Driver
author:         Intel Corporation, <>
srcversion:     AB58ACECA1618E521F58503
alias:          pci:v00008086d00001503sv*sd*bc*sc*i*


Disk Utility:

#du -sh file_path


du command estimates file_path space usage
The options -sh are (from man du):

-s, –summarize
display only a total for each argument

-h, –human-readable
print sizes in human readable format (e.g., 1K 234M 2G)
To check more than one directory and see the total, use du -sch:
-c, –total
produce a grand total

You could extend this command to:

#du -h –max-depth=1 | sort -hr

which will give you the size of all sub-folders (level 1). The output will be sorted (largest folder on top).

Print all usb devices:

#cat /proc/bus/input/devices

#cat /proc/bus/usb/devices

Grep tip:

For BSD or GNU grep you can use -B num to set how many lines before the match and -A num for the number of lines after the match.

#grep -B 3 -A 2 foo README.txt

If you want the same number of lines before and after you can use -C num.

#grep -C 3 foo README.txt

This will show 3 lines before and 3 lines after.



How to Split Terminal Screen in Linux Ubuntu 14.04




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s