Category: Ubuntu

Common Ubuntu Commands

The purpose of this blog is to inculcate the readers with some of the important network related commands and other command used on daily basis.

Rename multiple files in the same directory with extension phps to php.

$ rename ‘s/.phps$/.php/’ *.phps

History Command in Ubuntu

$history  //This command maintains history of the commands you applied

The output of this command displays serial number and command only. What if you want to know when that command is applied and at what time? What to do so that your history command always display date and time also?

Here is the answer of all questions.

HISTTIMEFORMAT="%d/%m/%y %T "

Or, to make the change permanent for the current user:

echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bashrc
source ~/.bashrc

Then

history

Command which tells which ports are open by firewall is.

$ nmap  127.0.0.1

Output

Starting Nmap 7.01 ( https://nmap.org ) at 2017-10-13 14:09 IST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000077s latency).
Not shown: 991 closed ports
PORT STATE SERVICE
22/tcp open ssh
25/tcp open smtp
80/tcp open http
110/tcp open pop3
139/tcp open netbios-ssn
143/tcp open imap
445/tcp open microsoft-ds
3306/tcp open mysql
5432/tcp open postgresql

Nmap done: 1 IP address (1 host up) scanned in 0.12 seconds

Command to print network connections, routing tables.

$ sudo netstat -nutlap | grep 25

tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 14277/master
tcp 0 0 172.20.10.3:47056 198.252.206.25:443 ESTABLISHED 2956/firefox
tcp 0 0 172.20.10.3:47596 198.252.206.25:443 ESTABLISHED 2956/firefox
tcp 0 0 172.20.10.3:47424 198.252.206.25:443 ESTABLISHED 2956/firefox
tcp 0 0 172.20.10.3:47618 198.252.206.25:443 ESTABLISHED 2956/firefox
tcp 0 0 172.20.10.3:47576 198.252.206.25:443 ESTABLISHED 2956/firefox
tcp 0 0 172.20.10.3:59342 54.251.241.152:443 TIME_WAIT –
tcp 0 0 172.20.10.3:47530 198.252.206.25:443 ESTABLISHED 2956/firefox
tcp 0 0 172.20.10.3:38490 54.251.58.133:443 TIME_WAIT –
tcp 0 0 172.20.10.3:51642 198.252.206.25:443 ESTABLISHED 2956/firefox
tcp6 0 0 :::25 :::* LISTEN 14277/master

SMTP Secure listen to port 465 and TLS listen to port 587

Command to open port

sudo ufw allow <port number>

eg:- sudo ufw allow 8082

To know more about Ubuntu commands read blogs under the same category.

Stay tuned! 🙂

 

Advertisements

Track CPU and Memory Usage and Time Command

Today, I tried to explore and customize Ubuntu.

Track CPU and Memory Usage in Ubuntu Using Indicator-Sysmonitor

It’s clearly explained in the following link.

https://www.maketecheasier.com/track-cpu-memory-indicator-sysmonitor/

Done.

Then to note time of consumption by a particular command. You can use command

$time <your command>

Example:- $ time renderd -f -c /usr/local/etc/renderd.conf

Output

real 9m34.716s
user 0m16.796s
sys 0m0.960s

Done.

For the first time I used bitbucket. It’s versioning control system.

For it install mercurial.

$ sudo apt install mercurial
$ hg clone https://bitbucket.org/lawgon/osmindia

 

 

Increase the Memory of Ubuntu Partition

Free/Unallocated Space

If you have not free space to extend the memory then shrink space from other partition. Below are the steps to do so.

  1. Open Gparted either from terminal or from dashboard.
  2. Right click on the partition you want to shrink.
  3. Click on Resize/Move and write the free space(in Mib) you want to unallocate.
  4. Click on Apply all operations (Tick button with a green color).

After this Start GParted in live Ubuntu session.

Also unmount (if they’re mounted) all the partitions that will be involved in the resize/move operation (by right clicking and selecting unmount from the context menu)

The partition you want to extend should be adjacent to the unallocated space. If not so, then we have move the in between partitions as was in my case.

gpar1.png

Here, I want to extend /dev/sda8 partition with 49.61 Gib unallocated space. But they are not adjacent to each other. So, I have to move the partition  /dev/sda6 to the left.

Right click on the partition /dev/sda6 and select move/Resize option. Drag the bar to the complete left.

(WARNING: moving /boot partition may cause boot failure!)

snapWarn

Click OK. You will able to see the progress. It might take an hour or more depending upon the number of operations and partition memory.

mov1

After the completion of a move the partitions was in the order as shown.

movv

Now, it’s time to extend the partition /dev/sda8 which was our main objective. So again right click and select Resize/Move option.

mov2

Extend the size of the window by expand it to left (in this case) and select Resize/Move.

In this case the partition will move to left as well grow.

mov5

mov6

Here, you can see the partition /dev/sda8 is increased by 49.61 Gib. Hope this blog would help you out.

For any queries or suggestions you may comment on this blog.

USB Bootable In Ubuntu

In my first blog, I explained how to bootable USB in windows through UUI. Today, I will discuss it in Ubuntu. Sounds interesting.;)

Search Start Up Disk Creater on dashboard and select it. It will pop up the window.

start.png

As shown in the figure you will be able to see the source disk image(.iso) or CD in your system. Select any one of them.

Then select the removable disk to be used to make it bootable.

Forward to click the option Make startup disk and you are done with it.

Format USB in Ubuntu

Format USB In Ubuntu

Search Disk on dashboard and select it. It will pop up the window.

Select the option of the disk you want to format.

Choose atleast 1 volume represented by it.

Select the gear(settings button popping for more actions) icon and click the option Format Partition.

format

You are done with it. Now you may safely eject your pendrive.:)

 

 

 

 

Youtube-dl Error

While downloading youtube video through youtube-dl command I was getting an error shown below.

amisha@amisha:~/you$ youtube-dl https://www.youtube.com/watch?v=Q-GOFPM01d0
Setting language
WARNING: unable to set language: <urlopen error [Errno 8] _ssl.c:510: EOF occurred in violation of protocol>
Q-GOFPM01d0: Downloading webpage
ERROR: Unable to download webpage: <urlopen error [Errno 8] _ssl.c:510: EOF occurred in violation of protocol>

Then I removed youtube-dl and installed it again.

sudo apt-get remove youtube-dl
sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl

And after that it works fine. Hope this may help you.

 

 

Task 1

Task 1

 

How to Dual boot Windows 7 and Ubuntu 14.04 and run c++ program in ubuntu

STEP   1 :-If windows is already installed on your PC then take backup of  your windows by

  1. click control panel
  2. click backup or restore your files
  3. click set up backup displaying at the side of your console and follow the wizard

1

STEP 2:-Disk  Partition

  1. Click Windows key +X and press disk management
  2. select the disk you want to partition
  3. right click on it and select shrink volume
  4. If you have 500 Gb harddisk then partition  around 60 Gb for ubuntu

2

It will create a free space.

  1. Then make your pendrive bootable and insert it to usb port.
  2. Shut down your computer
  3. Start  your computer and press corresponding function key of Bootup settings.

Click on USB drive option

3.jpg

STEP 3 :- Install OS

4.jpg

Click on install Ubuntu, then it will show..

5

Click on something else option…

6

Select the FREE SPACE option created by you. AND, click on + sign shown at th bottom.

7

8

Ext4 journaling file system is for LINUX  as  ntfs is for WINDOWS.Its for storing, retrieving data. Adjust size of your choice, or don’t change it.

On Mount point ,Select /

Then, go ahead. Enter your name, password etc. on the next screen complete some simple steps and finally click install.

Ubuntu-on-VirtualBox-16

10

STEP 4:- Change Boot Device

11

Set your BIOS boot order such that once again the hard drive is the primary boot device.

Restart your system and again go to BOOT SETUP as you did in step 3 and now select hard drive.
Note that if you skip this step, your system will try to load an operating system from removable media before looking for Windows. If there is not a disk in the drive, it should proceed to boot into Windows.

Step 6: Reboot and Configure

13

You will now see a choice between Windows and Ubuntu Linux. Go ahead and select Linux, and get yourself familiarized with this great OS.

WELCOME TO THE WORLD OF UBUNTU…..

14

 

NOW,THE Next Part……………

HOW TO RUN A C++ PROGRAM ON UBUNTU THROUGH CLI(COMMAND LINE INTERFACE i.e TERMINAL

Screenshot from 2016-02-01 16:35:27

$tep 1: Go to TERMINAL

make a directory let named ,test and then change the directory using commands

mkdir test

cd test

then, go to GEDIT OR VIM …these are the text editors for ubuntu there are
many more also..

you can install these via net or through UBUNTU SOFTWARE CENTER
furthur, write a c++ program in gedit and save it in test.

$tep 2: I AM HERE SHOWING A PROGRAM TO FIND FACTORIAL OF A NO.

Screenshot from 2016-02-07 18:48:55

here, ls command is for seeing list of programs in a particular selected directory…

.cpp is the extension on c++ file…….. I HAD SAVED THE PROGRAM BY NAME fact.cpp

g++ fact.cpp is for compilation

./a.out is for executing the program

…… YOU CAN RUN ANY OF your c++ program in this way, there is another example i m showing you here…

Screenshot from 2016-02-07 18:59:33

NOTE:

TERMINAL is CASE-SENSITIVE…

there is a command, clear used to clear the terminal