Tricks Linux Command Line

Tips & Tricks

I started using linux in 2009, along that time I’ve learned many ticks and useful comand lines, some of them barely use it, in that way, I decided to recompile all those tricks to make a post just for not forget them. Let’s do it.

Local and remote files (SSH sesions)

Copy a file from a local machine to a remote machine with SCP:

~$ scp /path_of_the_local_file/file username@domain:/path_of_the_remote_machine

Copy the file “foobar.txt” from a remote host to the local host

$ scp your_username@remotehost.edu:foobar.txt /some/local/directory

 

Iptables

Allowing Incoming Traffic on Specific Ports

~$ sudo iptables -A INPUT -p tcp –dport 22 -j ACCEPT

 

Storage Devices

Format an USB Device with dd:

$ dd bs=1M if=/dev/zero of=/dev/sdb

 

Stablishing a Serial Comunication RS232

Raspberry Pi Communication:

Having into account that we can make a serial communication through GPIO Raspberry Pi port, the first step is to identify transmission and reception pins, in this case those are the importat pins we have eventually to interconect

Pin Number 2 = Vcc = 5v
Pin Number 6 = GND = Ground
Pin Number 8 = Tx = Transmission
Pin Number 10= Rx = Reception

The GND, Tx and Rx pins are mandatory, VCC is optional just in case you want to supply the device by serial port, otherwise you can supply in other way and left VCC pin witout connect. The most important thing here is that you have to cross connect Rx and Tx lines, means you have to connect Rx line with Tx of the other device, see image below.

Using Debian distributions, in this case Ubuntu, you can use “screen” package to make the connection. Have into account the serial parameters. for Raspberry are the follows:

  • Speed Baud Rate: 115200
  • Bits: 8
  • Parity: None
  • Stop Bits: 1
  • Flow Control: None

The last 4 parameters are configurated by default in screen package, in that way we only have to set the baud rate. Finally once you connect the serial wire to your laptop you have to know wich port was assigned, you can use “dmesg” command to know it, usually those start with “tty”, in this case the system assigned “ttyUSB0”

In order to make the connection use the follow command.

$ screen /dev/ttyUSB0 115200

 

Up votes: Down votes: