Centered mostly around Ubuntu, dwm and gnome, which is what I use, and also a few applications such as Blender.
Do it by launching gconf-editor and navigating the tree to apps - nautilus - preferences and unticking the box for show_desktop, or from a shell:
gconftool --type boolean --set /apps/nautilus/preferences/show_desktop false
gconftool --type string --set /desktop/gnome/background/picture_filename "/path/to/your/image.png"
gnome-power-cmd.sh suspend gnome-power-cmd.sh hibernate gnome-power-cmd.sh shutdown
The above are generic commands. For a specific laptop such as a Thinkpad T60p running linux, you can have a look at the /etc/acpi folder for commands like sleep.sh.
If your sleep fails, running the command manually will show you, on the terminal, where and how it's failing.
gnome-screensaver-command -l
Some commands you may want to know.
To beautify gtk windows when not running gnome as a desktop:
$ gnome-settings-daemon &
To edit sound preferences:
$ gnome-sound-preferences &
To launch the power manager:
$ gnome-power-manager &
To launch the keyring daemon that stores your passwords:
$ gnome-keyring-daemon &
To turn on automounting (for your USB pen):
$ gnome-volume-manager &
If you are in the default ubuntu gnome or kde desktop, you don't need this at all. From outside, edit your ~/.bashrc with the following:
alias pen='sudo mount -o uid=1000,gid=1000 /dev/sdb1 /mnt/pen' alias upen='sudo umount /mnt/pen'
... and be sure that the directory /mnt/pen exists.
The uid and gid options enable a specific user to read/write to/from the pen. To check your own uid and gid, use the id command in a shell.
When more than one USB device is to be mounted, it will get the next letter: sdb, sdc, and so on.
What this lets you do is to serve music or sound in general from a machine, and listen to it in another, such as your laptop.
In your laptop, where you want to hear music, open a shell and type:
$ esd -tcp -public
In the server, to play the sound of a movie:
$ ESPEAKERS=192.168.2.18 mplayer -ao esd -af volume=10 /path/to/file.avi
Replace the above movie file path by a music file to play that instead.
Thanks to Mark Longair for this tip!
For some reason beyond my understanding, gnome doesn't mount network shares, which means most applications cannot find the files from the share -because they don't have a proper file system path.
To fix the situation, edit your /etc/fstab file with sudo privileges, and add an entry like the following, replacing username by your local username, and shareusername and shareuserpassword by your remote share username and password:
//some/netshare /home/username/local/folder smbfs username=shareusername,password=sharepassword,uid=username,gid=username,file_mode=0777,dir_mode=0777 0 0
As an alternative, the same may be accomplished from bash:
$ sudo mount -t cifs -o username=shareusername,password=sharepassword,uid=username,gid=username,file_mode=0777,dir_mode=0777 //some/netshare /home/username/local/folder
The following works fine for a Thinkpad T60p:
echo 0x2F 0x00 | sudo tee /proc/acpi/ibm/ecdump #(fan off) echo 0x2F 0x02 | sudo tee /proc/acpi/ibm/ecdump #(low speed) echo 0x2F 0x04 | sudo tee /proc/acpi/ibm/ecdump #(medium speed) echo 0x2F 0x07 | sudo tee /proc/acpi/ibm/ecdump # (maximum speed) echo 0x2F 0x80 | sudo tee /proc/acpi/ibm/ecdump #(automatic - default) echo 0x2F 0x40 | sudo tee /proc/acpi/ibm/ecdump #(disengaged)
Just issue each command (without the comment!) on a shell, and be careful no to fry your laptop by using an improper setting.
# xmms2 configuration # for the USB headset: xmms2 config alsa.device = hw:1,0 # for the volume xmms2 volume right = 80 xmms2 volume left = 80 # to list the configuration options xmms2 config_list | less # to play a file xmms2 play /path/to/music.mp3 xmms2 pause xmms2 stop xmms2 quit # to list the current playlist xmms2 list | less
The tunneling technique allows you access via ssh, scp and rsync to a server that is invisible to the outside world, but which sits behind a visible server. Any number of tunnels may be concatenated together.
In your local machine, type the following in a shell and live it open:
$ ssh -N -f -L 3333:remote_server_name:22 loginname@visible.server.com > password: <---- for your visible server!
Then open a second shell in the local machine and type:
$ rsync -Cavz some/local/folder loginname@localhost:3333/path/to/invisible/server/folder > password: <---- for your INvisible server!
If your invisible server contains a git repository, you can pull from it like the following. In your local machine, type:
$ cd /my/repos $ git pull ssh://loginname@visible.server.com:3333/path/to/invisible/repository
If you simply want to login to the invisible server, just type:
$ ssh -p 3333 loginame@visible.server.com
To copy a file from the invisible server to the local folder:
scp -C -P 3333 loginname@localhost:/path/to/invisible/server/file.txt .
#To create the new group 'wg': $ sudo addgroup wg # To add user 'stephan' to the group 'wg': $ sudo usermod -a -G wg stephan
Install vncserver first and launch it at DISPLAY 1:
$ sudo apt-get install xvncviewer vncserver <password: $ vncserver :1
Now any machine may connect to the server:
$ vncviewer
Tested on a Thinkpad T60p.
$ sudo hdparm -I /dev/sda
hdparm provides the ability to modify your hard drive settings. See man hdparm. USE WITH CARE.
To check the hard drive temperature, use:
$ sudo hddtemp /dev/sda
If you have more than one hard drive, try /dev/sdb, /dev/sdc etc.
Suppose you want to install the very latest version of a program that already exists in the ubuntu repositories.
First you need to get all development files for the programs on which it depends on:
$ sudo apt-get build-dep <program-name>
Second just compile the program. If the ubuntu version is not much far apart, it will compile just fine.
First make sure the Python Imaging Library is installed:
$ sudo apt-get install python-imaging
Then open a shell and type:
$ python
>>> import Image, ExifTags
>>> im = Image.open("/path/to/image.jpg")
>>> for key, value in sorted(im._getexit().items()):
>>> print key, ExifTags.TAGS.get(key), value
271 Make Canon
272 Model Canon PowerShot A85
274 Orientation 1
282 XResolution (180, 1)
283 YResolution (180, 1)
296 ResolutionUnit 2
306 DateTime 2005:08:14 10:24:05
531 YCbCrPositioning 1
33434 ExposureTime (1, 160)
...
Below, a <CR> means 'enter' or 'carriage return'. Just type as is, including 'data' (which starts the body of the message) and 'quit'.
telnet smtp.somewhere.com 25 helo my_username.somewhere.com mai from: <email-account>@username.somewhere.com rcpt to: <email-account>@username.somewhere.com data The body of the message goes here. . Quit
To reset a connection properly, use, at the end:
<CR> .<CR> RSET<CR> Quit<CR>
This is like navigating the internet manually.
$ telnet www.google.com 80 Trying 64.233.167.99... Connected to google.com. Escape character is '^]'.
Then type or paste (with middle click), quickly before it closes, and follow it by two pushes to enter key:
HEAD / HTTP/1.1
Which responds with:
HTTP/1.1 200 OK Cache-Control: private Content-Type: text/html; charset=ISO-8859-1 Set-Cookie: PREF=ID=20f45537f4fc5e16:TM=1211048229:LM=1211048229:S=s7sijCPqZ_4rpsvC; expires=Mon, 17-May-2010 18:17:09 GMT; path=/; domain=.google.com Date: Sat, 17 May 2008 18:17:09 GMT Server: gws Content-Length: 0
You can also try to fetch the whole page with (followed as well with 2 pushes to enter key):
GET / HTTP/1.1
Which prints the entire HTML code of the index page for google.com.
Have fun! With this simple command, one can write a web browser of sorts with very few lines of shell scripting or python or whatever.
This usage of nc lets you have some sort of chat with someone else who connect to your server via telnet.
For the server (where you can type text as well):
$ nc -l -p 3456
For the client (a.k.a. the other person connecting to you):
$ telnet xxx.xxx.xxx.xxx 3456
Where xxx.xxx... is the IP of the computer where the nc server was launched.
Make sure nmap is installed, then:
$ sudo nmap -sT -O -v 127.0.0.1
... which essentially runs a port scan on your local machine.
On each listed open port, now you can telnet to it and figure out what application daemon is behind it. For example, to test port 22:
$ telnet 127.0.0.1 22 Trying 127.0.0.1... Connected to localhost.localdomain. Escape character is '^]'. SSH-2.0-OpenSSH_4.3p2 Debian-5ubuntu1 ^] telnet> quit
If you do the port scan on a remote machine, the responses of the daemon check with telnet may be obfuscated or faked (intentionally), without your knowledge. Garbage in, garbage out.
sudo modprobe -r e1000 sudo modprobe e1000 sudo idown eth0 sudo ifup eth0
Use alsamixer command. Each sound output is named a "channel". So to access the USB headset, use channel 1:
$ alsamixer -c 1
To change which channel is being used as default, launch:
$ gnome-sound-properties
... although most applications like xmms or skype will let you do so from within the application preferences dialog.
Make sure wordnet is installed. Then use:
$ wn <some-word> -over
... which gives an overview of the meaning(s) of the word, usually with examples of usage. Other options include antonyms, synonyms, etc. See man wn.
I have included in my .xinitrc script, which is read when launching X with startx. Something you won't be doing most likely if you use a graphical login for linux.
# launch screensaver ensuring it is not running xscreensaver-command -exit xscreensaver &
To lock at any time, just type:
$ xscreensaver-command -lock
Add a file ~/.inputrc and write in it:
set bell-style none
(Can also take parameter 'visible' to flash the screen instead of just remaining mute.)
To list packages and find out from which repository:
$ for p in `dpkg -l |grep ^ii | tr -s " " | cut -d " " -f 2` ; do echo $p ; \
apt-cache show $p | grep ^Section: ; echo ; done | less
Listing all installed packages and sorting them by their installed size:
$ dpkg-query -W --showformat='${Installed-Size}\t${Package}\t${Status}\n' \
| grep "ok installed" | sort -gr | less
Or:
$ dpkg-query -Wf '${Installed-Size}\t${Package}\t${Status}\n' | sort -rg \
| grep "ok installed" | less
To force fsck on reboot:
$ sudo shutdown -F -r now
Or:
$ sudo touch /forcefsck $ sudo reboot
In linux:
lspci -v | less
In FreeBSD:
$ pciconf -l -v | less
Each graphics card usually has its own neat graphical application to do so (such as amdcccle for fglrx driver for ATI graphic cards.) But you can also use:
$ xgamma -rgamma 1.0 -ggamma 1.2 -bgamma 1.4
In a Thinkpad T60p:
$ cat /proc/acpi/ac_adapter/AC/state state: on-line $ cat /proc/acpi/battery/BAT0/state present: yes capacity state: ok charging state: charged present rate: 0 mW remaining capacity: 70720 mWh present voltage: 12492 mV
Other files under /proc/acpi are also useful to mine information about the state of the computer.
In ubuntu is really this simple:
$ sudo apt-get install apache php5 mysql-server-5.1 \
php5-mysql libapache-mod-php5 php5-gd
$ sudo vim /etc/apache/httpd.conf
$ sudo vim /etc/php5/apache2/php.ini
$ sudo /etc/init.d/apache restart
So you installed a new graphics card and perhaps a new monitor, and on reboot, ubuntu doesn't seem to work at all. No problem: