This is an old revision of the document!
Table of Contents
echo vs. printf
echo $var # is the same as... printf '%s\n' "$var" echo -n $var # is the same as... printf '%s' "$var"
find
Basic Syntax:
find /path/to/search/ -name searchTerm
If you get a bunch of garbage on the screen, send it all to /dev/null:
find /path/to/search/ -name searchTerm 2>/dev/null
Network Commands
Configs are found here.
see IP info
Pick one, they basically do the same thing:
ifconfig -a # Debian net-tools pkg ls /sys/class/net # ls interface names ip a ip a show ip a show eth0
manual up/down
Manually bringing your network up and down (nixCraft has a good explanation):
- Assuming eth0 (change for whichever interface you want to manipulate).
Generic Method:
ifdown eth0 # Turn off eth0 ifup eth0 # Turn on eth0
Use a specific configuration file:
ifdown wlan0 # bring interface down ifup --interfaces /path/to/file/interface_config_file wlan0
Debian Method (as root):
/etc/init.d/networking restart # Restarts network interfaces, or stop/start... /etc/init.d/networking stop # Stops network interfaces /etc/init.d/networking start # Starts network interfaces systemctl restart networking # For those with lovely systemd systemctl status network # See status of network systemd
ifupdown vs. ifconfig
Debian, overview:
ifup
andifdown
control interfaces that are listed in/etc/network/interfaces
.ifconfig
directly controls network interfaces (much like the newerip
command)
The ifupdown
package: high-level network configuration
- The
ifup
andifdown
commands may be used to configure or deconfigure network interfaces based on interface definitions in the file/etc/network/interfaces
. - Example: bring up the network with
ifup eth0
based on eth0 configuration in/etc/network/interfaces
. ifupdown
will wrapifconfig
with the network configuration files (i.e.,ifdown
orifup
will executeifconfig down
orifconfig up
inside it). That means:ifup eth0
will fetch the interface config file and bring up the interface with the correct IP address, mask, routes etc.ifconfig eth0
up would just start the interface with no IP, etc. (important for sniffing in monitor mode because you don't want an IP address, etc.; you want an open broadcase).
The ifconfig
command: a low-level network command (and deprecated, sadly)
- An
ifconfig up eth0
activates eth0 but does not setup IP addresses, etc. - An
ifup eth0
sets up IP addresses and other options based on the interface's configuration in/etc/network/interfaces
.
ip command
Usage of the ip
command:
- If your distro did not install ifconfig, you can install it in Debian with
apt install net-tools
. - From the following example you will need to replace the IP and the interface with your own.
[1] Assign an IP address to a specific interface:
ip addr add 192.168.0.100/24 dev eth0
[2] Bring up the interface link (do NOT skip this step or you will get a “Network is unreachable” error!):
ip link set eth0 up
[3] Bring up the interface link:
ip route add default via 192.168.0.1
[1-3] All in one place… looks like this:
ip addr add 192.168.0.100/24 dev eth0 ip link set eth0 up ip route add default via 192.168.0.1
Note on Persistence: This will only set up your network for your current work session. You'll lose it on reboot.
ip
(like the old net-toolsifconfig
stuff) interacts with/etc/network/interfaces
, so put all your network configuration information there and just up/down your network with these commands:
/etc/init.d/networking restart # Restarts network interfaces, or stop/start... /etc/init.d/networking stop # Stops network interfaces /etc/init.d/networking start # Starts network interfaces