Category Archives: Linux Commands

Convert Document format on ubuntu

Convert .odt to .doc

libreoffice --headless --convert-to doc *.odt

Convert .odt to .docx

libreoffice --headless --convert-to docx *.odt

Convert .doc to .docx

libreoffice --headless --convert-to docx *.doc

Add text beginning and end of the file using command

Add text in the beginning of the file

  1. Suppose you had a text file with the contents and you wanted to insert a string to the beginning:
    1st line
    2nd line
    3rd line
  2. Run the command:
    sed -i '1i Top of the file!' <filename>
  3. Now the file will look like this:
    Top of the file!
    1st line
    2nd line
    3rd line

A brief explanation of the sed command parameters that we used:
-i : This will update the contents of the file and automatically save it
1i : This means, insert to the 1st line of the file

Add text at the end of the file

  1. To append the string “hello” to file greetings.txt
    echo "hello" >> greetings.txt
  2. To append the contents of the file temp.txt to file data.txt
    cat temp.txt >> data.txt
  3. To append the current date/time timestamp to the file dates.txt
    date >> dates.txt

Find Out Which Process Is Listening Upon a Port

netstat – a command-line tool that displays network connections, routing tables, and a number of network interface statistics.

$ sudo netstat -plnt

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0* LISTEN  1158/mysqld
tcp 0 0* LISTEN 5390/redis-server 1
tcp 0 0* LISTEN 699/smbd
tcp 0 0* LISTEN 4938/openvassd: Wai
tcp 0 0* LISTEN 2218/dnsmasq
tcp 0 0* LISTEN 1345/dnsmasq
tcp 0 0* LISTEN 1029/sshd
tcp 0 0* LISTEN 7420/cupsd
tcp 0 0* LISTEN 1320/teamviewerd
tcp 0 0* LISTEN 1271/postgres
tcp 0 0* LISTEN 2140/master
tcp 0 0* LISTEN 699/smbd
tcp6 0 0 :::139 :::* LISTEN 699/smbd
tcp6 0 0 :::9390 :::* LISTEN 4962/openvasmd
tcp6 0 0 :::9392 :::* LISTEN 5442/gsad
tcp6 0 0 :::80 :::* LISTEN 2367/apache2
tcp6 0 0 :::22 :::* LISTEN 1029/sshd
tcp6 0 0 ::1:631 :::* LISTEN 7420/cupsd
tcp6 0 0 :::25 :::* LISTEN 2140/master
tcp6 0 0 :::443 :::* LISTEN 5201/gsad
tcp6 0 0 :::445 :::* LISTEN 699/smbd