RSS

Monthly Archives: September 2017

Common Linux Commands

1.  ls   list all the contents of a directory  (Display One File Per Line Using ls -1 | Display File Size in Human Readable Format Using ls -lh | Display Hidden Files Using ls -a (or) ls -A | )

2. ll list all the contents of a directory with its permissions, size etc

3. cd / cd .. move in an out of directories

4. mv / cp:         Copy file1 to file2 preserving the mode, ownership and timestamp.

$ cp -p file1 file2

Copy file1 to file2. if file2 exists prompt for confirmation before overwritting it.

$ cp -i file1 file2

mv command examples

Rename file1 to file2. if file2 exists prompt for confirmation before overwritting it.

$ mv -i file1 file2

Note: mv -f is just the opposite, which will overwrite file2 without prompting.

mv -v will print what is happening during file rename, which is useful in some cases.

$ mv -v file1 file2

5. man to find documentation about a command

6. mkdir: to make a directory

mkdir command examples Following example creates a directory called temp under your home directory.

$ mkdir ~/temp

Create nested directories using one mkdir command. If any of these directories exist already, it will not display any error. If any of these directories doesn’t exist, it will create them.

$ mkdir -p dir1/dir2/dir3/dir4/

7. rmdir  to delete a directory

8. touch to create an empty file

9.rm  to remove a file

10. clear (same as cls in winows) clear the clutter from terminal window

11. rm -rf / << the command that we should never use. it will clean the whole system. 

12.TAR: Create a new tar archive.

$ tar cvf archive_name.tar dirname/

Extract from an existing tar archive.

$ tar xvf archive_name.tar

View an existing tar archive.

$ tar tvf archive_name.tar

13. grep : to extract data. check example.

nesi@Alpha:~$ ip route
default via 192.168.1.1 dev enp7s0  proto static  metric 100
default via 192.168.75.3 dev wlp6s0  proto static  metric 600
192.168.1.0/24 dev enp7s0  proto kernel  scope link  src 192.168.1.95  metric 100
192.168.75.0/24 dev wlp6s0  proto kernel  scope link  src 192.168.75.94  metric 600
192.168.250.0/24 dev anbox0  proto kernel  scope link  src 192.168.250.1
nesi@Alpha:~$ ip route | grep default 
default via 192.168.1.1 dev enp7s0  proto static  metric 100
default via 192.168.75.3 dev wlp6s0  proto static  metric 600

14. sudo / su:
su command examples : Switch to a different user account using su command. Super user can switch to any other user without entering their password. some linux distributions nowadays only allow sudo.

$ su - USERNAME

Execute a single command from a different account name. In the following example, john can execute the ls command as raj username. Once the command is executed, it will come back to john’s account.

[john@dev-server]$ su - raj -c 'ls'

[john@dev-server]$

Sudo: is same like “run as administrator” in windows

15. pwd (print working directory) show us the current directory in which the terminal is running on.

16. ps show currently running processes

17. passwd command  : Change your password from command line using passwd. This will prompt for the old password followed by the new password.

$ passwd

Super user can use passwd command to reset others password. This will not prompt for current password of the user.

# passwd USERNAME

Remove password for a specific user. Root user can disable password for a specific user. Once the password is disabled, the user can login without entering the password.

# passwd -d USERNAME

18. ifconfig command :  Use ifconfig command to view or configure a network interface on the Linux system.View all the interfaces along with status.

$ ifconfig -a

Start or stop a specific interface using up and down command as shown below.

$ ifconfig eth0 up

$ ifconfig eth0 down

set IP and SM :

$ ifconfig eth0 192.168.50.5 netmask 255.255.255.0

linux-network-configuration-and-troubleshooting-commands

19. uname command : Uname command displays important information about the system such as — Kernel name, Host name, Kernel release number,
Processor type, etc.,Sample uname output from a Ubuntu laptop is shown below.

$ uname -a
Linux Alpha 4.10.0-35-generic #39~16.04.1-Ubuntu SMP Wed Sep 13 09:02:42 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

20. whatis command : Whatis command displays a single line description about a command.

$ whatis ls
ls		(1)  - list directory contents

$ whatis ifconfig
ifconfig (8)         - configure a network interface

21. whereis command : When you want to find out where a specific Unix command exists (for example, where does ls command exists?), you can execute the following command.

$ whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1.gz

22. locate command : Using locate command you can quickly search for the location of a specific file (or group of files). Locate command uses the database created by updatedb. The example below shows all files in the system that contains the word crontab in it.

$ locate crontab
/etc/anacrontab
/etc/crontab
/usr/bin/crontab
/usr/share/doc/cron/examples/crontab2english.pl.gz
/usr/share/man/man1/crontab.1.gz

23. tail command : read a text file on terminal.
usage examples: Print the last 10 lines of a file by default.

$ tail filename.txt

Print N number of lines from the file named filename.txt N refers to the number of lines you want to print

$ tail -n N filename.txt

View the content of the file in real time using tail -f. This is useful to view the log files, that keeps growing. The command can be terminated using CTRL-C.

$ tail -f log-file

24. less command : less is very efficient while viewing huge log files, as it doesn’t need to load the full file while opening.

$ less huge-log-file.log

One you open a file using less command, following two keys are very helpful.

CTRL+F – forward one window
CTRL+B – backward one window

25. Kill Command – Kill the process by specifying its PID:  to kill conventions by sending the TERM signal to the specified process. For the signals, either the signal name or signal number can be used. You need to lookup the pid (process ID) for the process and give it as an argument to kill. Use PS or Top to find pid 
exmple:

nesi@Alpha:~$ ps
  PID TTY          TIME CMD
11671 pts/1    00:00:00 bash
12194 pts/1    00:00:00 ps
nesi@Alpha:~$ top
9658 nesi      20   0 1790380 367880  32344 S  12.5  9.3   1:00.76 chromium-b+ 
 3604 nesi       9 -11  592688   6124   4160 S   6.2  0.2   3:39.36 pulseaudio  
12212 nesi      20   0   59776   3524   2948 R   6.2  0.1   0:00.01 top         
    1 root      20   0  185312   2104    840 S   0.0  0.1   0:01.52 systemd     
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.01 kthreadd    
    4 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:+ 
    6 root      20   0       0      0      0 S   0.0  0.0   0:00.15 ksoftirqd/0 
nesi@Alpha:~$ kill 9658

in this case the kill command will kill the chromium app

26. Xkill Command – kill a client by X resource:  xkill is the simplest way to kill a malfunctioning program. When you want to kill a process, initiate xkill which will offer an cross-hair cursor. Click on the window with left cursor which will kill that process. command: xkill

27top shows information about the top processes in the system (sorted by CPU usage by default): top may not be installed by default. Htop is another app that gives a more detailed approach to this purpose.

28. alias : to assign an alias for a command. for example, to update our package repositories we need to run “ sudo apt-get update” which is a long command. using alias we can make it shorter like may be “update” see the another example below:
we often ping to google to check if our internet is working.

nesi@Alpha:~$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=58 time=87.8 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=58 time=86.4 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=58 time=86.6 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=58 time=87.2 ms
nesi@Alpha:~$ alias g='ping 8.8.8.8'
nesi@Alpha:~$ g
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=58 time=87.5 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=58 time=86.5 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=58 time=86.7 ms

29. apt / apt-get | install, update, dist-upgrade, remove etc : APT-GET How to

30. hostname : display the host name of the system (in case if you want to change the hostname of your laptop, you have to do it inside /etc/hosts file. open it up in gedit or any other text editor and change it. Ex: “sudo gedit /etc/hosts” )

31. uptime – Reports how long the system has been running since last boot. Extremely useful for servers.

32. lsb_release -a or –all: Displays some relevan all of the above information. For instance, if you are running Arch Linux, this will display
LSB Version: 1.4
Distributor ID: Arch
Description: Arch Linux
Release: rolling
Codename: n/a
   (lsb_release is part of a software package called the LSB core, which is not necessarily installed on your system by default. to install on ubuntu: sudo apt-get update && sudo apt-get install lsb-core | on CentOS :sudo yum update && sudo yum install redhat-lsb-core)

33. who : shows the list of currently logged in users.

34. shutdown: shuts down your computer. You can use shutdown -r to restart your computer. (you may have to run it as root, sudo /su)

 
Leave a comment

Posted by on September 28, 2017 in Linux

 

Tags: , , , ,

Reset a Windows 10 password with CMD

requirement = installation Disk of any windows 7,8,8.1,10

boot into the boot disk. instead of install we will select repair.

then go to trouble shoot options. search for cmd

when you find it. launch it. by default cmd will open to a directory name x:> we will need to change that to the drive where windows is installed. to do this do the following
type in    c:
this will get us into C drive. type in dir to list all the content. if the list doesn’t show the items of Windows partition. you are not in the right drive. change the drive, D: or E: do this until you find the drive.

now we will move to the the system32 folder cd windows\system32 when we get here. rename the osk.exe file to osk.old. to do this run the follwing command.

rename osk.exe osk.old

now rename cmd.exe to osk.exe
same as above
rename cmd.exe osk.exe

As per design when we are on the login screen of windows there is a on screen keyboard (osk.exe) available to us. by following the above steps we have just replaced that keyboard with command prompt.

now restart and boot into the system (not the boot disk). when we are on the login screen with the user account to which we forgot the password.

open the accessibility option and click on on screen keyboard. which will launch cmd.exe

to list all users of the system :

net user

when we know the actual username of the account we want to change password.

net user [USERNAME] *

[USERNAME] refer to the account whose password we are trying to change.

if you are planning to change password and enable the built in administrator
net user administrator /active:yes
is a compulsory step.

after running the above command a new password prompt is shown. assign a new password for the account. close the cmd. and use the new pass to login.

after this don’t forget to change everything as they were.

to do this; boot into the os-disk and undo all the changes.

rename osk.exe cmd.exe
rename osk.old osk.exe

deactivate the built in administrator if you no longer need it.

thats all!

 
2 Comments

Posted by on September 28, 2017 in Windows

 

Tags: , , , , ,

Windows useful apps

  1. TreeSize Free: Even in the times of cheap terabytes a final truth remains: Sooner or later every hard disk will near capacity. But there is help! TreeSize Free tells you where precious disk space has gone. Use the treemap to keep an eye on your disk space.
 
Leave a comment

Posted by on September 17, 2017 in Windows

 

Tags: , , ,

Pantheon-Mail stretches horizontally across screen eOS

I read about this error before but never faced it, until today.

I ran a sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade to make my lap up to date. and ended up with to problems. Hopefully I can Fix them. 1. Pantheon-Mail now stretches horizontally across the screen. 2. when I click “network settings” from drop-down menu of network icon on wing panel, it opens “system settings”.

after a brief googling I found solution for the first one.

kill or close pantheon-mail then run the following command on terminal.

dconf reset -f /org/pantheon/mail/

Which will reset the settings of Mail to default. For me after running this it was solved.

(some user said this is not a permanent solution and i may have to run the same when it appears again! )

 
Leave a comment

Posted by on September 14, 2017 in Linux

 

Tags: , , , , , , ,

Comedy Anime that I really enjoyed

1. ✓   KonoSuba: God’s Blessing on this Wonderful World! (2016) :  Japanese:この素晴らしい世界に祝福を! Hepburn:Kono Subarashii Sekai ni Shukufuku o! [ studio: Studio Deen ]  10/10
(detailed review: @peachsalmanac)

2. ✓    Daily Lives of High School Boys (2012)Japanese: 男子高校生の日常 Hepburn: Danshi Kōkōsei no Nichijō [directer: Daigo Matsui | Studio: Sunrise ]  10/10

3. ✓   The Devil Is a Part-Timer! (2013): Japanese: はたらく魔王さま! Hepburn: Hataraku Maō-sama!,  (literally Working Demon King! or Demon Lord at Work!) [Directer:  white fox | Studio:  Naoto Hosoda ] 10/10

4. ✓   My Neighbor Seki (2014) : Japanese: となりの関くん Hepburn: Tonari no Seki-kun [directer: Yūji Mutoh | Studio: Shin-Ei Animation ]  10/10

5. ✓   Barakamon (2014)Japanese: ばらかもん [directer: Masaki Tachibana | Studio: Kinema Citrus ]  10/10

  1.  
 
2 Comments

Posted by on September 11, 2017 in Anime

 

Tags: , , ,

Enscapsulation

The term “encapsulation” is used to describe a process of adding headers and trailers around some data. For example, when you send an email using your favorite email program (like Outlook or Thunderbird) that email is sent from the Application layer to the Transport layer. The Transport layer encapsulates the data and adds its own header (with its own information, such as which port will be used) and passes the data to the Internet layer, which again encapsulates the received data and adds its own header, usually with information about the source and destination IP addresses. The Internet layer than passes the data to the Network Access layer. This layer is the only layer that adds both a header and a trailer. The data is then sent through a physical network link.

Each layer adds its own information:

encapsulation

The term “decapsulation” refers to the process of removing headers and trailers as data passes from lower to upper layers. This process happens on a computer that is receiving data.

Frame, packet, segment

 
Frame – the term “frame” refers to the encapsulated data defined by the Network Access layer. A frame can have a header and a trailer that encapsulate a data section.
Packet – the term “packet” is used to describe the encapsulated data defined by the Internet layer. A packet can have a header with the source and destination IP addresses.
Segment – the term “segment” describes encapsulated data defined by the Transport layer. A segment can have a header with informations such as source and destionation port numbers, sequence and acknowledgment numbers, etc.
 
Leave a comment

Posted by on September 10, 2017 in CISCO

 

Tags: , , , , , ,

OSI Model

OSI Model is a 7 layer model created to define a standard for networking. Even though it was meant to be a protocol, nowadays ISO/OSI is just a model. Whereas TCP/IP is the protocol (or collection of protocols) modern networks follow.


7. Application:  (DataUnit: Data )

Here are your applications. E-mail, browsing the web (HTTP), FTP and many more.


6. Presentation(DataUnit: Data )

This one will make sure that information is readable for the application layer by formatting and structuring the data. Most computers use the ASCII table for characters. If another computer would use another character like EBCDIC than the presentation layer needs to “reformat” the data so both computers agree on the same characters.

Data representation and Encryption is done in this layer


5. Session(DataUnit: Data )

The session layer takes care of establishing, managing and termination of sessions between two hosts. When you are browsing a website on the internet you are probably not the only user of the web-server hosting that website. This web-server needs to keep track of all the different “sessions”.


4. Transport(DataUnit: Segments )

The transport layer takes care of transport. While browsing Internet webpages are sent as segments and transported to your computer. segments great chunks of data received from the upper layer protocols. Establishes and terminates connections between two computers. Used for flow control and data recovery.

  • TCP lives here; it’s a protocol which send data in a reliable way.  (TCP Windowing, Three way handshake )
  • UDP lives here; it’s a protocol which sends data in an unreliable way.

3. Network(DataUnit: Packets )

This layer takes care of connectivity and path selection (routing). This is where IPv4 and IPv6 live. Every network device needs a unique address on the network. defines device addressing, routing, and path determination. Device (logical) addressing is used to identify a host on a network (e.g. by its IP address).


2. Data link(DataUnit: Frames )

This layer makes sure data is formatted the correct way, takes care of error detection and makes sure data is delivered reliably. This is where “Ethernet” lives. MAC Addresses and Ethernet frames are on the Data Link layer. encapsulates a packet in a frame. A frame contains a header and a trailer that enable devices to communicate. A header, most commonly, contains a source and a destination MAC address. A trailer contains the Frame Check Sequence field, which is used to detect transmission errors.
The data link layer has two sublayers:

1. Logical Link Control – used for flow control and error detection
2. Media Access Control – used for hardware addressing and controlling the access method


1. Physical(DataUnit: Bits )

This layer describes stuff like voltage levels, timing, physical data rates, physical connectors and so on. Everything you can “touch” since it’s physical. defines how to move bits from one device to another. It details how cables, connectors and network interface cards are going to work and how to send and receive bits.

 
Leave a comment

Posted by on September 10, 2017 in CISCO

 

Tags: , , , , , , , , , , ,

Windows Photo viewer on Win 10

copy+paste the following code to a notepad file and save it as a “.reg” file. then run as administrator. this will enable photo-viewer.  after it is enabled go to control panel > default programs> select “windows photo viewer” > set default to all applicable extensions. then open an image it may open in the new image viewer. to change this go to properties of the image file and change default app.

NB: even after it got enabled ‘old photo viewer ‘ may not appear in ‘new default apps menu of win 10″

 Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll]

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell]

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\open]
"MuiVerb"="@photoviewer.dll,-3043"

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\open\command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,72,00,75,00,\
6e,00,64,00,6c,00,6c,00,33,00,32,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,\
00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,46,00,69,00,6c,00,65,00,73,00,\
25,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,20,00,50,00,68,00,6f,\
00,74,00,6f,00,20,00,56,00,69,00,65,00,77,00,65,00,72,00,5c,00,50,00,68,00,\
6f,00,74,00,6f,00,56,00,69,00,65,00,77,00,65,00,72,00,2e,00,64,00,6c,00,6c,\
00,22,00,2c,00,20,00,49,00,6d,00,61,00,67,00,65,00,56,00,69,00,65,00,77,00,\
5f,00,46,00,75,00,6c,00,6c,00,73,00,63,00,72,00,65,00,65,00,6e,00,20,00,25,\
00,31,00,00,00

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\open\DropTarget]
"Clsid"="{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}"

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\print]

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\print\command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,72,00,75,00,\
6e,00,64,00,6c,00,6c,00,33,00,32,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,\
00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,46,00,69,00,6c,00,65,00,73,00,\
25,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,20,00,50,00,68,00,6f,\
00,74,00,6f,00,20,00,56,00,69,00,65,00,77,00,65,00,72,00,5c,00,50,00,68,00,\
6f,00,74,00,6f,00,56,00,69,00,65,00,77,00,65,00,72,00,2e,00,64,00,6c,00,6c,\
00,22,00,2c,00,20,00,49,00,6d,00,61,00,67,00,65,00,56,00,69,00,65,00,77,00,\
5f,00,46,00,75,00,6c,00,6c,00,73,00,63,00,72,00,65,00,65,00,6e,00,20,00,25,\
00,31,00,00,00

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\print\DropTarget]
"Clsid"="{60fd46de-f830-4894-a628-6fa81bc0190d}" 
 
Leave a comment

Posted by on September 10, 2017 in Windows

 

Tags: , , ,

create permanent alias eOS

Create a file name .bash_aliases in home directory
Then when we need to create a alias open that file in text editor(in my case: Gedit) with root privileges.

sudo gedit ~/.bash_aliases

then create whatever alias you want inside the text file
eg:
alias update="sudo apt-get update"
and save the text file.
as you may have noticed I assigned “update” to “sudo apt-get update”
now whenever I type in the command ‘Update’ on to the terminal it will run “sudo apt-get update”


In the latest versions of Ubuntu, ~/.bashrc automatically sources ~/.bash_aliases, so permanent aliases are best put into this file instead. previously we used to put permanent aliases on  ~/.bashrc

 
Leave a comment

Posted by on September 8, 2017 in Linux

 

Tags: , , , , , ,

Check which is the default file manager – eOS loki

I was in a situation where i couldn’t identify which is my default file manager. after a brief google search I ended up with the following command

what’s the current default file manager?

xdg-mime query default inode/directory

 

 
Leave a comment

Posted by on September 8, 2017 in Linux

 

Tags: , , , , ,