How to mount a USB Drive in Linux

First naviagte to the MNT directory!

root@xxxxxx:/# ls
bin dev home lib64 media opt root sbin sys usr
boot etc lib lost+found mnt proc run srv tmp var

root@axxxxx:/# cd mnt
root@xxxxxx:/mnt# ls

root@xxxxxx:/# !Here no storage devices mounted(Note)

Creating a Mount point
A mount point is a location on your directory tree to mount the partition.
The default location is /media although you may use alternate locations such as /mnt or your home directory.

Note: we are using /mnt here to mount point (mnt) and the partition (usbdrive).

root@xxxxxx:/# mkdir /mnt/usbdrive
root@xxxxxx:/#
root@xxxxxx:/#
root@xxxxxx:/# ls /mnt/
usbdrive

Here the usb drive partition is created

Mounting the USB Drive

root@xxxxxx:/# mount /dev/sdc
sdc sdc1
Note: Here i used “TAB” to display both device node

root@xxxxxx:/# mount /dev/sdc1 /mnt/usbdrive/

Now listing the mount driveand partition we have
root@xxxxxx:/# ls mnt/usbdrive/
dump lost+found

https://wiki.archlinux.org/index.php/USB_storage_devices

https://help.ubuntu.com/community/Fstab

How to switch users in Linux

How to switch users in Linux on the command line using “sudo su”

su, also referred to as substitute user, super user, or switch user, is used by a computer user to execute commands with the privileges of another user account. When executed it invokes a shell without changing the current working directory or the user environment.

root@test-VirtualBox:~# su test
test@test-VirtualBox:/root$

changing to root user

test@test-VirtualBox:/$ sudo -i

 

Linux Network Configuration Commands

ifconfig Commands needed to Configure Network Interface in Linux

ifconfig in simply means interface configuration.utility for system/network administration in
Unix/Linux operating systems to configure, manage and query network interface parameters via command line
interface or in a system configuration scripts.

The “ifconfig” command is used for displaying current network configuration information,
setting up an IP address, netmask or broadcast address to a network interface,
creating an alias for the network interface, setting up hardware address and enable or disable network interfaces.

1. ifconfig
The “ifconfig” command with no arguments will display all the active interface details.
The ifconfig command also used to check the assigned IP address of a server.
root@pve:~# ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:xx:69:73:bd

2. Display Information of All Network Interfaces
ifconfig command with -a argument displays information of all active or inactive network
interfaces on the server.
root@pve:~# ifconfig -a

3.View Network Settings of Specific Interface
Using the interface name (eth0) as an argument with the “ifconfig” command will display details of specific network interface.
root@pve:~# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 08:00:xx:69:73:xx
inet6 addr: fe80::a00:xxxx:fe69:73bd/64 Scope:Link

4.Enabling an Network Interface
The “up” or “ifup” flag with interface name (eth0) activates a network interface, if it is not in active state and allowing to send and receive information. For example, “ifconfig eth0 up” or “ifup eth0” will activate the eth0 interface.
root@pve:~# ifconfig eth0 up
root@pve:~#
root@pve:~# !both commands can be used to achieve the same result.
root@pve:~#
root@pve:~# ifup eth0

5.Disabling an Network Interface
root@pve:~# ifconfig eth0 down
The semaphore timeout period has expired.
root@pve:~# !both commands can be used to achieve the same result to shutdown as well.
root@pve:~#
root@pve:~#ifdown eth0

6. Assigning an IP Address to a Network Interface
To assign an IP address to a specific interface, use the following command with an interface name (eth0) and ip address that you want to set.
root@pve:~# ifconfig eth0 172.xx.25.1xx
This will set the IP address to interface eth0

7. Assigning an IP Address to a Netmask to Network Interface
Using the “ifconfig” command with “netmask” argument and interface name as (eth0) allows you to define a netmask to a given interface.
For example, “ifconfig eth0 netmask 255.255.xxx.22x” will set the network mask to a given interface eth0.
root@pve:~# ifconfig eth0 netmask 255.255.xxx.22x

8. How to Assign a Broadcast to Network Interface
Using the “broadcast” argument with an interface name will set the broadcast address for the given interface.
For example, “ifconfig eth0 broadcast 172.xx.25.xx” command sets the broadcast address to an interface eth0.
root@pve:~# ifconfig eth0 broadcast 172.xx.25.xxx

9. How to Assign a IP, Netmask and Broadcast to Network Interface
To assign an IP address, Netmask address and Broadcast address all at once using “ifconfig” command with all arguments as given below.
root@pve:~# ifconfig eth0 172.xx.25.xx netmask 255.255.xxx.xx broadcast 172.xx.25.xx

10. How to Change MTU for a Network Interface
The “mtu” argument sets the maximum transmission unit to an interface.
The MTU allows you to set the limit size of packets that are transmitted on an interface.
The MTU able to handle a maximum number of octets to an interface in one single transaction.
For example, “ifconfig eth0 MTU 1000” will set the maximum transmission unit to a given set (i.e. 1000). Not all network interfaces support MTU settings.

root@pve:~#ifconfig eth0 mtu 1000

11. How to Enable Promiscuous Mode
What happens in normal mode, when a packet received by a network card,
it verifies that the packet belongs to itself. If not, it drops the packet normally, but in the promiscuous mode is used to accept all the packets that flows through the network card.

Most of the today’s network tools uses the promiscuous mode to capture and analyze the packets that
flows through the network interface.
To set the promiscuous mode, use the following command.
root@pve:~#ifconfig eth0 promisc


12. How to Disable Promiscuous Mode
To disable promiscuous mode, use the “-promisc” switch that drops back the network interface in normal mode.
root@pve:~#ifconfig eth0 -promisc

13. How to Change the MAC address of Network Interface
To change the MAC (Media Access Control) address of an eth0 network interface, use the following command with the argument “hw ether“.
root@pve:~#ifconfig eth0 hw ether AA:BB:CC:DD:EE:FF

How To Check the Kernel Version in Linux / Ubuntu / CentOS

root@pve:/# uname –help
Usage: uname [OPTION]…
Print certain system information. With no OPTION, same as -s.

-a, –all print all information, in the following order,
except omit -p and -i if unknown:
-s, –kernel-name print the kernel name
-n, –nodename print the network node hostname
-r, –kernel-release print the kernel release
-v, –kernel-version print the kernel version
-m, –machine print the machine hardware name
-p, –processor print the processor type or “unknown”
-i, –hardware-platform print the hardware platform or “unknown”
-o, –operating-system print the operating system
–help display this help and exit
–version output version information and exit

With these commands followed by the respective option,

The following command works with all Linux distributions, such as Red Hat, CentOS, Debian, and Ubuntu.
It also works on other UNIX-like operating systems such as HPUX, FreeBSD, OpenBSD, Solaris, etc.

Use the following command to check which kernel version your server is currently running:

root@pve:/# uname -r

How to find out what version of Linux (distro) you are running,

root@pve:/# cat etc/*-release
PRETTY_NAME=”Debian GNU/Linux 7 (wheezy)”
NAME=”Debian GNU/Linux”
VERSION_ID=”7″
VERSION=”7 (wheezy)”
ID=debian
ANSI_COLOR=”1;31″
HOME_URL=”http://www.debian.org/”
SUPPORT_URL=”http://www.debian.org/support/”
BUG_REPORT_URL=”http://bugs.debian.org/”
root@pve:/#

 

Linux Installation and Configuration of OpenSSH SSH Server

Run from the terminal and type the following command to update package database as root user:
# apt-get update

# apt-get upgrade

Now install OpenSSH server by typing the following command:

# apt-get install openssh-server
After installation, by default
By default openssh will run on the TCP port 22. You can verify the same with the following command:
# netstat -tulpn | grep :22

How to configure Secure OpenSSH Server from the default port

You need to edit the /etc/ssh/sshd_config file using any of the text editors such as nano,

simply run:
# vi /etc/ssh/sshd_config

How Do I Start / Stop / Restart OpenSSH Server in Linux?

Type the following commands as a root user:
# service ssh stop
# service ssh start
# service ssh restart
# service ssh status

OR

# /etc/init.d/ssh stop
# /etc/init.d/ssh start
# /etc/init.d/ssh restart
# /etc/init.d/ssh status

Relevant link: http://www.cyberciti.biz/faq/debian-linux-install-openssh-sshd-server/

Linux Error 13: (Permission denied) are you root?

This error simply means you are not the root user.

me@linuxbox ~#apt-get update
E: Could not open lock file /var/lib/dpkg/lock – open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
Solution
simply install it using the sudo to install any package as a root user.
This occurs because you are using a normal user account

You forgot the sudo for the second command.
me@linuxbox ~#sudo apt-get update && sudo apt-get upgrade will work.