Ubuntu commands for people who don't know Linux
- Restart the machine:
sudo shutdown -r now
- Create a new user:
useradd {username}
- Checking for disk space on available volumes:
df -hcommand - Check for size of folders in current working directory:
du -h --max-depth=1
- Create .tar.gz / .tgz files:
tar -czvf {output.tgz} {folder} - Extract .tar.gz / .tgz files:
tar -xzvf {input.tgz} {path} - Create .zip files:
zip -r {output.zip} {folder} - Extract .zip files to directory:
unzip {input.zip} -d {folder} - Watch a log file real-time:
tail -f {file} - Find files containing text:
grep -Rl {search} {path}or case insensitivegrep -Rli {search} {path} - Download a file from the internet:
wget {url} - Back up your stuff locally:
rsync {source} {destination} - Back up your stuff to another server:
rsync -avz -e ssh {path} {user}@{host}:{path}
- Make a file executable:
chmod +x {filename}
- Inspect the current PATH variables:
echo $PATH - Append directory to the existing PATH:
export PATH=$PATH:/path/to/binary - Declare a new environment variable:
export {variable}=/path/to/binary - Edit system-wide environment variables:
nano /etc/environment - Create an alias for a command:
nano ~/.bash_aliasesfollowed byalias {alias name}='{command}'
- Kill a process:
kill {pid} - See all running processes:
ps aux - Get PIDs of running processes under a specific name:
ps aux | grep {name}orps aux | grep {name} | awk '{print $2}'
- Modify the host name:
sudo nano /etc/hostname - Set a static IP address:
sudo nano /etc/network/interfaces - Modify hosts:
sudo nano /etc/hosts
- Check existing cron jobs:
crontab -e
- What IP adress is assiged to me?
ifconfig - What TCP/IP ports are open and what programs are listening on them?
lsof -i -P(needs to have lsof installed and be run as root) - Where do I configure my network interfaces?
vi /etc/network/interfacesthen runifdown <interface>and thenifup <interface> - What are the details of a specific network interface?
iwlist <interface> scan - Connect to a specific wireless network for a given interface?
iwconfig <interface> essid "<ssid name>" - Get an IP address assigned from a router?
dhclient <interface> - How do I list all NAT rules?
iptables -L - What are all of the available network devices for this machine?
lspci
- How do I install MySQL? Stab a fork in your eye and install Postgres instead.