Ir para o conteúdo
ou

Software livre Brasil

Tela cheia Sugerir um artigo
 Feed RSS

CommandLineFu

4 de Junho de 2009, 0:00 , por Software Livre Brasil - | Ninguém está seguindo este artigo ainda.

Troca de conhecimentos sobre o uso da linha de comando e referencia direta ao site commandlinefu.com.


Mount a VMware virtual disk (.vmdk) file on a Linux box

25 de Setembro de 2014, 23:05, por Commands with 10 up-votes - 0sem comentários ainda$ kpartx -av <image-flat.vmdk>; mount -o /dev/mapper/loop0p1 /mnt/vmdk

This does not require you to know the partition offset, kpartx will find all partitions in the image and create loopback devices for them automatically. This works for all types of images (dd of hard drives, img, etc) not just vmkd. You can also activate LVM volumes in the image by running

vgchange -a y

and then you can mount the LV inside the image.

To unmount the image, umount the partition/LV, deactivate the VG for the image

vgchange -a n <volume_group>

then run

kpartx -dv <image-flad.vmdk>

to remove the partition mappings.

commandlinefu.com

Diff your entire server config at ScriptRock.com



Simple multi-user encrypted chat server for 5 users

7 de Junho de 2014, 16:17, por Software Livre Brasil - 0sem comentários ainda$ ncat -vlm 5 --ssl --chat 9876

Client ~$ ncat --ssl localhost 9876

Change localhost to the correct ip address.

commandlinefu.com

by David Winterbottom (codeinthehole.com)



Silently ensures that a FS is mounted on the given mount point (checks if it's OK, otherwise unmount, create dir and mount)

12 de Abril de 2014, 8:23, por Software Livre Brasil - 0sem comentários ainda$ (mountpoint -q "/media/mpdr1" && df /media/mpdr1/* > /dev/null 2>&1) || ((sudo umount "/media/mpdr1" > /dev/null 2>&1 || true) && (sudo mkdir "/media/mpdr1" > /dev/null 2>&1 || true) && sudo mount "/dev/sdd1" "/media/mpdr1")

In my example, the mount point is /media/mpdr1 and the FS is /dev/sdd1

/mountpoint-path = /media/mpdr1

filesystem=/dev/sdd1

Why this command ?

Well, in fact, with some external devices I used to face some issues : during data transfer from the device to the internal drive, some errors occurred and the device was unmounted and remounted again in a different folder.

In such situations, the command mountpoint gave a positive result even if the FS wasn't properly mounted, that's why I added the df part.

And if the device is not properly mounted, the command tries to unmount, to create the folder (if it exists already it will also work) and finally mount the FS on the given mount point.

commandlinefu.com

by David Winterbottom (codeinthehole.com)



sniff network traffic on a given interface and displays the IP addresses of the machines communicating with the current host (one IP per line)

11 de Abril de 2014, 19:41, por Software Livre Brasil - 0sem comentários ainda$ sudo tcpdump -i wlan0 -n ip | awk '{ print gensub(/(.*)\..*/,"\\1","g",$3), $4, gensub(/(.*)\..*/,"\\1","g",$5) }' | awk -F " > " '{print $1"\n"$2}'

commandlinefu.com

by David Winterbottom (codeinthehole.com)



Given a file path, unplug the USB device on which the file is located (the file must be on an USB device !)

6 de Abril de 2014, 9:06, por Software Livre Brasil - 0sem comentários ainda$ echo $(sudo lshw -businfo | grep -B 1 -m 1 $(df "/path/to/file" | tail -1 | awk '{print $1}' | cut -c 6-8) | head -n 1 | awk '{print $1}' | cut -c 5- | tr ":" "-") | sudo tee /sys/bus/usb/drivers/usb/unbind

You have an external USB drive or key.

Apply this command (using the file path of anything on your device) and it will simulate the unplug of this device.

If you just want the port, just type :

echo $(sudo lshw -businfo | grep -B 1 -m 1 $(df "/path/to/file" | tail -1 | awk '{print $1}' | cut -c 6-8) | head -n 1 | awk '{print $1}' | cut -c 5- | tr ":" "-")

commandlinefu.com

by David Winterbottom (codeinthehole.com)



Check if your ISP is intercepting DNS queries

9 de Fevereiro de 2014, 17:24, por Software Livre Brasil - 0sem comentários ainda$ dig +short which.opendns.com txt @208.67.220.220

It's somewhat common ISPs to intercept DNS queries at port 53 and resolve them at their own.

To check if your ISP is intercepting your DNS queries just type this command in the terminal.

"#.abc" it's an OK answer.

But if you get something like "I am not an OpenDNS resolver.", yep, you are beign cheated by your ISP.

commandlinefu.com

by David Winterbottom (codeinthehole.com)



quick copy

22 de Janeiro de 2014, 12:09, por Software Livre Brasil - 0sem comentários ainda$ cp foo{,bak}

Utilizes shell expansion of {} to give the original filename and a new filename as arguments to `cp`. Can easily be extended to make multiple copies.

commandlinefu.com

by David Winterbottom (codeinthehole.com)



Generate QR code for a WiFi hotspot

28 de Dezembro de 2013, 17:40, por Software Livre Brasil - 0sem comentários ainda$ qrencode -s 7 -o qr-wifi.png "WIFI:S:$(zenity --entry --text="Network name (SSID)" --title="Create WiFi QR");T:WPA;P:$(zenity --password --title="Wifi Password");;"

Prompts for network name (SSID) and password, and generates (as qr-wifi.png) a WiFi QR code (e.g. "WIFI:S:mynet;T:WPA;P:mypass;;" for mynet/mypass). Dependencies [sudo apt-get install]: qrencode zenity

commandlinefu.com

by David Winterbottom (codeinthehole.com)



Download all mp3's listed in an html page

11 de Dezembro de 2013, 7:21, por Software Livre Brasil - 0sem comentários ainda$ wget -r -l1 -H -t1 -nd -N -np -A.mp3 -erobots=off [url of website]

commandlinefu.com

by David Winterbottom (codeinthehole.com)



Sending a file over icmp with hping

23 de Outubro de 2013, 12:01, por Software Livre Brasil - 0sem comentários ainda$ hping3 10.0.2.254 --icmp --sign MSGID1 -d 50 -c 1 --file a_file

you need to start a listening hping on the reciever:

hping3 --listen 10.0.2.254 -I eth0 --sign MSGID1

then you can send your file:

hping3 10.0.2.254 --icmp --sign MSGID1 -d 50 -c 1 --file a_file

commandlinefu.com

by David Winterbottom (codeinthehole.com)



Tags deste artigo: cli commandline unix terminal