Showing posts with label terminal. Show all posts
Showing posts with label terminal. Show all posts

06 December, 2017

#How_Do_I_Find_Out_Linux_Gateway / #Router_IP_Address?

How do I find out my #gateway IP for a #computer or a #network device that allows or controls access to another computer or network under #Linux / #UNIX operating systems?
The ansver is almost simple for unix users...

A gateway is a network point that acts as an entrance to another network. On the Internet, a node or stopping point can be either a gateway node or a host (end-point) node. Both the computers of Internet users and the computers that serve pages to users are host nodes. The computers that control traffic within your company’s network or at your local Internet service provider (ISP) are gateway nodes. In the network for an enterprise, a computer server acting as a gateway node is often also acting as a proxy server and a firewall server. A gateway is often associated with both a router, which knows where to direct a given packet of data that arrives at the gateway, and a switch, which furnishes the actual path in and out of the gateway for a given packet.

You need to use route command. Open an Terminal and type this command will show you #IP_routing_tables. It can be also use to print gateway / router IP address. Type the following command to see #default_gateway:

$ route -n
Output:

Kernel IP routing table
Destination    Gateway       Genmask           Flags   Metric   Ref   Use   Iface
0.0.0.0           192.168.1.1   0.0.0.0               UG     100         0      0       enp5s0
192.168.1.0   0.0.0.0           255.255.255.0   U        100         0      0       enp5s0

192.168.1.1 is gateway IP address for our computer.
The flag:
U indicates that route is up
G indicates that it is gateway.

12 December, 2015

How to turn off / on NetworkManager from terminal?

If you don't want to have your inteface make a DHCP request, simply edit it (right on network manager applet, choose "Edit Connections", click on the interface in question, then choose the IPv4 tab and change "Automatic (DHCP)" to "Manual" and specify your settings manually.

If you need to turn off network manager regardless, use
sudo service network-manager stop
You can specify stop, start or restart for most services.
ends commands you can use: stop, start and restart

02 April, 2013

Filetransfer via SSH (terminal) on Linux/Unix

SSH File Transfers

Though FTP has been commonly used in the School of Computing and by many other sites across the globe, it suffers a severe lack of security by passing a user's login information, including their password, via plain text across the network. In order to avoid such a blatent security hole, we are using the encrypted SSH protocol for logins and file transfers. This document is meant to be a quick guide on using SSH/SFTP for file transfers on UNIX and Windows machines.
    Note: MacOSX users, via the Terminal application, can use the command line to perform file transfers, as UNIX systems are described below.
Note: To use SSH/SFTP from an SoC Facility UNIX machine, You will need /uusoc/bin in your PATH environment variable to access the programs mentioned in this guide.


Unix - Unix

Transferring files between two Unix systems using SSH is handled by two simple command line programs, scp and sftp.

SCP

I'm using SCP, for saving transfer time, If you have a few files or big files to transfer, you can save time by using the scp command instead of sftp. scp works much like rcp, for those who are familiar with the remote shell tools. All interaction is handled on the command line. File transfers can be done in either direction. Using the same files from our example above, transferring them using scp would work like this:
    > scp "remotemachine:/server/homework/*.txt" .
    myfile1.txt              |          3 KB |   3.3 kB/s | ETA: 00:00:00 | 100%
    myfile2.txt              |          0 KB |   0.8 kB/s | ETA: 00:00:00 | 100%
    myfile3.txt              |          6 KB |   6.3 kB/s | ETA: 00:00:00 | 100%
    >
     
    or something like this 
     
    $ sudo scp  "user@remote:/from/public/dir\ some\ place\ you\ have/*" toyourdir
    user@remote's password:  
Notice that the wildcard listing for the remote machine must be in double quote marks for the string to be passed correctly. The period at the end of the line tells scp to copy the files to the current directory of the local machine. Of course, you can specify any local directory that you can write to, like /tmp or /tmp/mydir or ./mydir.
Transferring files to a remote machine is done in much the same way:
    > scp *.txt remotemachine:.
    myfile1.txt              |          3 KB |   3.3 kB/s | ETA: 00:00:00 | 100%
    myfile2.txt              |          0 KB |   0.8 kB/s | ETA: 00:00:00 | 100%
    myfile3.txt              |          6 KB |   6.3 kB/s | ETA: 00:00:00 | 100%
    >
Note that the wildcard string does not need quotes when specifying files on the local machine. Also, the remotemachine:." tells scp to use your home directory on the remote system. Again, you can use any directory you can write to, like remotemachine:/tmp

 

SFTP

As the name might imply, sftp works much like a regular ftp client, but transfers are all made across an encrypted channel. To establish a secure ftp connection to a machine, simply use:
 sftp

You will be prompted for your password/passphrase and then dropped into an ftp-like prompt. Typing a "?" at the prompt will show you supported commands.
    sftp> ?
    Available commands:
    cd path                       Change remote directory to 'path'
    lcd path                      Change local directory to 'path'
    chgrp grp path                Change group of file 'path' to 'grp'
    chmod mode path               Change permissions of file 'path' to
    'mode'
    chown own path                Change owner of file 'path' to 'own'
    help                          Display this help text
    get remote-path [local-path]  Download file
    lls [ls-options [path]]       Display local directory listing
    ln oldpath newpath            Symlink remote file
    lmkdir path                   Create local directory
    lpwd                          Print local working directory
    ls [path]                     Display remote directory listing
    lumask umask                  Set local umask to 'umask'
    mkdir path                    Create remote directory
    put local-path [remote-path]  Upload file
    pwd                           Display remote working directory
    exit                          Quit sftp
    quit                          Quit sftp
    rename oldpath newpath        Rename remote file
    rmdir path                    Remove remote directory
    rm path                       Delete remote file
    symlink oldpath newpath       Symlink remote file
    version                       Show SFTP version
    !command                      Execute 'command' in local shell
    !                             Escape to local shell
    ?                             Synonym for help
    sftp>
Navigation through directories is that same as with a standard shell, ls, cd, rm, et cetera. cd will change your working directory on the remote machine and lcd will change your working directory on your local system.
The actual file transfer process is handled with the get and put commands.
For our example, lets say that you want to grab a couple of files off of a remote Unix machine, which are located in /server/homework. Once you have connected and entered your password, you would simple use:
    cd /server/homework
to reach the desired directory. Using the ls command will show you the files within.
    sftp> ls
    myfile1.txt
    myfile2.txt
    myfile3.txt
    sftp>
In order to transfer these files to your local machine, you would use get and then the names of the files you wish to transfer. Standard Unix wildcards apply. For example:
    sftp> get *.txt
    myfile1.txt:..................................................................
    3397 bytes received in 0.03 secs,   104.90 K/s
    myfile2.txt:..................................................................
    791 bytes received in 0.01 secs,    56.70 K/s
    myfile3.txt:..................................................................
    6441 bytes received in 0.02 secs,   219.65 K/s
    sftp>
sftp will show you the size of the files transfered and how long it took for each file. The put command will transfer files from your local machine to the remote system in much the same way. Users familiar with standard ftp clients might be a little confused about selecting "binary" or "ASCII" transfer mode. Don't worry about it, binary mode is the only mode that sftp supports, the commands are simply there as legacy.

. Please refer to the man pages for sftp and scp references beyond the scope of this guide. 

10 February, 2013

How to check Linux distribution and version?

  • Start your terminal and just simply enter the command below to show your the linux distribution info.
     
     $ cat /etc/*-release                    
     
     
  • Here’s my result in one of my Linux boxes.
     
     $ cat /etc/*-release                    
    DISTRIB_ID=LinuxMint                     
    DISTRIB_RELEASE=14                       
    DISTRIB_CODENAME=nadia                   
    DISTRIB_DESCRIPTION="Linux Mint 14 Nadia"
    NAME="Ubuntu"                            
    VERSION="12.10, Quantal Quetzal"         
    ID=ubuntu                                
    ID_LIKE=debian                           
    PRETTY_NAME="Ubuntu quantal (12.10)"     
    VERSION_ID="12.10"                       

15 January, 2013

...connect to a Wireless Network from Terminal...

How do I connect to a Wireless Network from Terminal-only?


View available wireless networks:
Code:
iwlist  scan
(Replacing with your wireless interface [for example mine is eth2)
If you don't get any networks listed:

Code:
ifconfig  up
To turn on your wireless interface.
If your wireless network is WPA encrypted:

Code:
iwconfig  essid  key s:
(Note: I use "s:" so that I can enter my key in ASCII form e.g. "Kll4Wx"
If your network isn't secured:

Code:
iwconfig  essid 
I hope this helps, if you want more help just let me know!

12 June, 2012

how to check TXT record with "dig"


just simple, open your terminal and type:

# dig -t txt domain.com


; <<>> DiG 9.8.1-P1 <<>> -t txt domain.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 30723
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 0

;; QUESTION SECTION:
;domain.com.            IN    TXT

;; ANSWER SECTION:
domain.com.        3600    IN    TXT    "v=spf1 mx ip4:69.63.211.0/25 ip4:64.85.73.0/25 ip4:70.103.251.0/24 ip4:63.251.171.160/27 ip4:216.34.94.160/27 include:rnmk.com include:custhelp.com include:salesforce.com include:emailbrain.com -all"

;; AUTHORITY SECTION:
domain.com.        79923    IN    NS    ns3.domain.com.
domain.com.        79923    IN    NS    ns1.domain.com.
domain.com.        79923    IN    NS    ns2.domain.com.

;; Query time: 124 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Tue Jun 12 00:13:48 2012
;; MSG SIZE  rcvd: 293

06 November, 2010

how to remove symbolic-link (ln -s) on Linux

remove symbolic-link (ln -s) in terminal

When you create a link with "ln -s", then you can remove the link with a simple "rm"

"rm ACTUAL_FILE" removes the actual file, "rm SYM_LINK" removes the symbolic link

rm -rf /usr/src/linux

14 May, 2010

How to install OpenGL on Ubuntu?



OpenGL on Ubuntu is easy to install, here is one of the way to installing OpenGL,
open terminal and type in:

sudo apt-get update

sudo apt-get install libglu1-mesa-dev freeglut3-dev mesa-common-dev
 
 

08 February, 2010

How to delete files older then x-days on Linux

Delete Files Older then x Days on Linux - easy way
in terminal / command line

using "find" command

Code:
find *.txt -mtime +30 | xargs rm
  • "find" executing program
  • "*.txt" file
  • "-mtime +30" files older then 30 days
  • " | " pipe
  • "xargs" executing program
  • "rm" executing command

22 September, 2008

How to download bittorrent file in Terminal on Ubuntu ???



How to download thru bittorrent in terminal, on Ubuntu ? it's simpel..
open terminal. (if you don't have bittorrent installed yet.)
type:
:~$ sudo apt-get install bittorrent
after installation is finish.
change to directory you want download to

download a torrent file from the web ,
eks. wget file.torrent
it will download to that directory you are in,
then type:
:~$ btdownloadcurses file.torrent
and download will begin. have fun

if you have some comment please write...