|
|
|
|
|
|
|
Useful Ubuntu Linux Commands
|
|
Linux commands can be far from intuitive, with files related to a single application seemingly scattered throughout various locations, such as usr, bin, etc, var. This can make it difficult to recall how to invoke certain essential but not every-day commands. This page lists these commands in a single place. |
Rich, 6 September 07
Updated 8 December 08
|
Switch to a Virtual Terminal from the command line sudo chvt 1
Reset WINE (equivalent to a reboot in Windows) wineboot
Restart the pulseaudio deamon pulseaudio -k; pulseaudio -D
Restart Apache2 on Ubuntu sudo /etc/init.d/apache2 restart
View Apache2 error log gedit /var/log/apache2/error.log
This location is also where apache keeps its access.log file.
Force Disk Check on Next Reboot sudo touch /forcefsck
Reload Apache2 Config Settings sudo /etc/init.d/apache2 force-reload
Install Apache2 Module (eg ModRewrite) sudo a2enmod module_name
eg sudo a2enmod rewrite
Then force Apache to reload config settings as above.
Regenerate the fonts cache: sudo fc-cache -fv
The default location of system fonts is /usr/share/fonts/. Different font types are grouped into subfolders off here.
Create a symbolic link ln -s /path/to/target /path/to/linkname
Change the target of an existing symbolic link ln -s /path/to/target /path/to/linkname --force
If the link already exists, this command will change it so it links to the specified target location. If it doesn't already exist, it will be created as normal.
Copy a file over a network via SSH ssh -l {login_name} 192.168.0.XXX cat /path/to/target > /path/to/outputfile
Shortcuts for Eclipse IDE Lower Case: CTRL+SHIFT+Y Upper Case: CTRL+SHIFT+X
Jump to Matching Bracket: CTRL+SHIFT+P
Copy current line(s) and place them above/below: CTRL+ALT+UP/DOWN Move current line(s): ALT+UP/DOWN
Comment/uncomment current line(s): CTRL+/
Close current file: CTRL+W
Find open file: CTRL+E
Import Gzipped MySQL Database on the command line
gunzip < /path/to/database.sql.gz | mysql -u root -D databasename
The final -D databasename option for the mysql client selects the named database, and is only necessary when the gzipped SQL file doesn't begin with a USE databasename command.
Unix for loop syntax
The following returns every line in all files called build.mk in all subdirectories of the current working directory which contain the text 'bird', along with the name of each file:
for filename in `find . -name *.mk`; do grep -H bird $filename; done
Typical output might be:
./src/mozilla/extensions/build.mk:# Ben Turner mozilla@bongbirdnest.com
The name and path of each file appears, a colon then the actual line containing the string 'bird'.
Mount an ISO Image in Unix
sudo mount -o loop /path/to/iso /path/to/mount/point
Replace Underscores with Spaces in File and Directory Names
ls | while read filename ; do echo "$filename" | grep "_" >/dev/null 2>&1 ; if [ $? -eq 0 ] ; then newfilename=`echo "$filename" | tr "_" " "`; mv "$filename" "$newfilename" ; echo "renamed \"$filename\" to \"$newfilename\"" ; fi ; done |
|
|
|
|
|
|
|
|