Comenzi utile in Linux - Ubuntu/Kubuntu & Co
Usability settings:
-
move window-bar action buttons from left (Ubuntu 10.10/Mac) to right:
gconftool-2 --type string --set /apps/metacity/general/button_layout "menu:minimize,maximize,close" -
remove confirmation for logout: System Settings -> Advanced -> Session Manager -> Confirm Logout
-
remove screen-lock after screensaver: Control Center -> Screensaver -> Lock screen when screensaver is active (uncheck)
Processes management:
-
move a process to background (suspend):
CTRL-z -
list background/suspended processes:
jobs -
bring process to foreground:
fg 1
Computer info:
Inventory:
-
# lists your hardware
$ sudo lshw -
# lists all hard disk
$ sudo lshw -C disk -
# xports an html page with hardware details
$ sudo lshw -html > your-file-name.html
Sensors monitoring:
-
sudo apt-get install lm-sensors sensors-applet -
sudo sensors-detect
To see if your running kernel is 32-bit or 64-bit, just issue the following command:
-
$ uname -m
How to find out the Ubuntu / Kubuntu version:
-
Debian:
cat /etc/debian_version -
Ubuntu / Kubuntu:
-
cat /etc/issue -
lsb-release -a
-
Change default browser:
-
update-alternatives --config x-www-browser
Display (only) symbolic links with details
-
sudo find / -type l -print | xargs ls -lh
Display files/folder space usage
-
GUI: -
`FileLight, Disk Space Analyzer or gdmap` (Gnome) -
KDiskFree or [KDirStat](http://kdirstat.sourceforge.net/ "KDirStat")(KDE) -
CLI: -
ncdu - interactive tool
-
df -h
-
du -bsh {FOLDER_NAME}
-
du —max-depth=1 * | sort -n
-
Find the top 10 biggest files: find . -type f -print0 | xargs -0 du -s | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}
Manage iso images and CD/DVD’s:
Create ISO imags from CD/DVD:
$ dd if=/dev/dvd of=dvd.iso # for dvd $ dd if=/dev/cdrom of=cd.iso # for cdrom $ dd if=/dev/scd0 of=cd.iso # if cdrom is scsi These commands are useful for data CD/DVD images. For Audio CD’s there’s another (longer) story. (A simpler way would be to use specialized apps like: K3b, Acetoneiso, Brasero)
Create ISO image from folders:
$ mkisofs -v -o /tmp/user-folder.iso -R /home/user/user-folder
Write ISO images to CD/DVD:
- Find out your CDR/W SCSI address/device name:
$ cdrecord -scanbus - Write ISO image:
$ cdrecord -v -dao dev=1,0,0 speed=8 file.iso(Where,-speed=XX: Specify writing speed,-v: Verbose output,-dev: The virtual SCSI ID of the writing device [discovered with the earlier command])
Mount / Umount / Format
-
sudo mount /dev/sdb1 /media/USB -t vfat -
sudo umount /dev/sdb1 -
sudo mkfs -t vfat /dev/sdb1 -
sudo eject /dev/sdb1
Install software packages:
Subiectul este destul de bine detaliat aici. Pe scurt:
-
.tar.gz / .tar.bz2:
-
extract sources:
-
tar xzvf tarballname.tar.gz -
tar xjvf tarballname.tar.bz2
-
-
configure:
-
cd tarballname -
./configure
-
-
compile sources:
-
make -
sudo checkinstall
-
-
-
.deb:
-
graphic mode: double-click the file
-
console:
sudo dpkg -i file.deb
-
-
.rpm:
-
conversion in .deb:
sudo alien -k file.rpm -
install:
sudo dpkg -i file.deb
-
Calculate md5 checksums:
-
for a string:
echo -n "aaaaaa" | md5sum -
for a file:
md5sum file
For Loop in Bash:
-
The simple bash loop to do something with all files in the directory is:
for f in * ; do echo $f ; donewhich just displays all files in this case.
This is easy, what I usually need and often forget how to do it is to execute some action exact number of times. Something like simple for loop in C or Java. And there is an exact match for such loop in Bash too:
for (( i=1 ; iI found another similar solution on the Internet today at spiralbound.net:
for i in $(seq 1 100); do echo $i ; done
Renamefiles:
-
UPPERCASE → lowercase
rename ‘y/A-Z/a-z/’ *
Empty existing files / Create new (temporary) files:
-
echo "" > file -
cp /dev/null file -
dd if=/dev/zero of=output.file bs=1 count=1 -
cat /dev/null > your_file -
>filename -
touch /tmp/newfilename -
command:
mktempwhich outputs something like:/tmp/tmp.yTfJX35144script example:#!/bin/bash OUT=$(mktemp /tmp/output.XXXXXXXXXX) || { echo "Failed to create temp file"; exit 1; } echo "Today is $(date)" >> $OUT
Switch from openjdk to sunjdk
OpenJDK is included in a number or popular Linux distributions. The procedure below explains how to switch to Oracle (Sun) JDK 1.6 in Ubuntu.
-
Enable the Canonical Partner Software through the following steps:
Go to
Ubuntu Software Center. ClickEdit. ClickSoftware Sources. Switch to theOther Softwaretab and checkCanonical Partners. This may take some time. -
In the
Commandprompt, type the following sequence of commands:sudo apt-get update