The Glenbot

Code and other thoughts about geeky stuff

Glen Zangirolami – Python developer, musician, sailor, creator.
           
Also check out my photography!

Useful Linux Commands and Files

Posted on November 9th, 2009 –  0 comments  –  linux  ubuntu 

On an almost daily bases I work in Linux (Ubuntu).

I research and find commands that are useful to my daily work routine and save them in evernote.

Here is a compiled list of commands I commonly use. Share!

Grab Useful Linux commands and files with Google Docs

Download Useful Linux commands and files in Word format

Download Useful Linux commands and files in Evernote format

Users & Groups:

adduser <username> (add user to the system. Will create /home/<username> folder.)

adduser --group <groupname> <username> (add user to a group)

id <username> (display users id, groupid, and group information)

userdel -r <username> (remove user from system and home directory)

/etc/groups (file that holds all the groups in the system)

System:

cat /proc/meminfo (check the memory usage of the system)

vmstat (summary of the memory usage)

free -m (another summary of the memory usage)

ps -u <username> -o pid,rss,command (check memory usage under a specific user)

saidar (realtime monitor of system usage. Installed from apt-get)

pgrep (search for running processes)

kill <pid> (kill a running process by process id)

pidof <processname> (get the process id of a process by name)

Networking:

/etc/init.d/networking restart - (restart the network)

iftab (file that stores manual information of the NIC cards like mac address. Exists in older systems)

ifup ethx (bring a NIC up)

ifdown ethx - (bring a NIC down)

ifconfig (similar to ipconfig in windows. It display the networks properties)

/etc/network/interfaces (file that stores the settings for all NIC cards)

netstat -plntu (shows the open ports and what is listening on them)

iptables -L (displays the current configuration of the tables)

FTP/SSH:

/etc/ftpusers (list of users allowed and not allowed to connect to the machine via ftp)

/etc/ssh/sshd_config (config file for open ssh)

/etc/init.d/sshd restart (restart the open ssh services)

File System:

sudo (run a command as the super user)

pwd (shows the present working directory)

cp (copy a file from one location to another)

cp -R dir newdir (copy a fill directory from one place to another)

mv (move a file from one location to another)

rm (remove a file or folder)

rm -rf (remove files and folders recursively)

rm link (remove a symbollic link)

cat (display the contents of a file)

ln -s (create a symbolic link)

mkdir (make a folder)

df -h (get hard drive and partition usage)

find . -type d -print0 | xargs -0 chmod 755 (chmod all folders in a given folder)

find . -type f -print0 | xargs -0 chmod 444 (chmod all files in a given folder)

find . -mtime -1 -print > last_modified_24hours.txt (find files modified within last 24 hours)

Web & Packages:

wget (download a file from the internet. Usage: wget <addresstofile>)

apt-get update (updates the package in the Advanced packaging tool.)

apt-get install <application> (downloads and installs a linux package. i.e mysql squid etc.)

/etc/apt/sources.list (file that lists the advanced packaging tools (apt-get) sites)

Text Editors:

nano (a great easy to use text editor)

vi (a basic text editor for linux)

Apache:

/etc/init.d/apache2 (start, stop, or restart the apache server)

a2ensite (enable a site in sites-available)

a2dissite (disable a site in sites-available)

/usr/sbin/apache2ctl -k graceful (gracefully restart apache)

Subversion:

sudo svn export -r HEAD file:///var/svn/repository/tron/trunk/ folderorfilename (export files from a specific svn folder)

svn co urltorepository (check out files from a remote or local repository)

Mysql:

mysql -u root -p (connect to mysql with use root)

Comments (0)

Drop me a line or two...