Some assorted odds and ends in no particular order to save me re-Googling this kind of stuff…
Itentify if you are 32-bit or 64-bit
$ uname -a
Convert png into jpg
$ convert file.png file.jpg
To open KDE Advanced Text Editor (kate) with root priviliges:
$ kdesu kate
… and enter root password when prompted.
Set group ownership of a file/folder:
$ chgrp GroupName MyFolder
Change smb passwords:
Specifically, change a users smb password in the smbpasswd file
$ smbpasswd -a foo
Find IP address for Linux server on the LAN:
$ /sbin/ifconfig
Check versions of MySql, Perl, gcc etc:
$ mysql -V
$ perl -v
$ gcc -v
Identify GCC compiler version used in application
% strings - yourapp | grep GCC
Display CPU information:
$ cat /proc/cpuinfo
Find a file from root directory and all sub-directories:
$ find / -name 'myfile.txt'
Extract and install from tar.gz files:
$ gunzip file.tar.gz
$ tar -xvf file.tar
cd to that directory, and:
$ ./configure
$ make
$ sudo make install
$ clean install
Linux File Permissions Overview:
drwxrwxrwx 1 user group 4096 2005-09-20 21:37 MyDir
first column: file type: d/- directory/file
columns 2-10: rwx permissions for user / group / other respectively
followed by number of links, file/dir owner, group that dir/file belongs to, file size (bytes), date/time of last modification, file/dir name.
Changing file permissions in numerical mode:
$ chmod 755 MyDir
This would change the MyDir’s permissions to drwxr-xr-x. The owner would have full read, write, and execute permissions (7=4+2+1), the group would have read and execute permissions (5=4+0+1), and the others would have the read and execute permissions as well.
Changing file permissions in symbolic mode:
For example, to add write permission for the group use
$ chmod g+w MyDir
Checking if software installed
For SuSE, Redhat, Fedora etc:
$ rpm -qa | grep emacs
For Ubuntu / Debian:
$ dpkg -s emacs
Finding the directory path of files and commands
$ which emacs
Update a boot sequence
For SuSE, Redhat, Fedora etc:
$ chkconfig --set SomeService on
For Ubuntu / Debian:
$ update-rc.d SomeService defaults
Install a new package in Ubuntu Linux
$ sudo apt-get install build-essential
Search directory and it’s subdirectories for a text string
$ grep -r 'text' /dir
To print the filenames only:
grep -lr 'lhs' programs/
To seach and print files of a particular type
$ grep -lr --include='*.java' 'text' dir/
Find changes made between main root branch and project branch in SVN
$ svn log -v -r 1001768:HEAD http://svnserver.ubiquity.net/svn/product/branches/sb4.0/root/ > changes.txt
Display current working directory path
$ pwd
Display all current processes
$ ps aux | less
Display available disk space
$ df
Zip files and directories
For example, to compress all files of extension *.cpp or *.h into ExpressionParser.zip:
$ zip ExpressionParser *.cpp *.h
To recursively compress a directory and its sub-directories to a zip file:
$ zip -r ZipFileName DirectoryName/
Cancel all print jobs
$ lprm -
Mount a windows partition
$sudo sudo blkid
This will list your devices (partition):
/dev/sda1: LABEL="Local Disk" UUID="5AEC8638EC860F07" TYPE="ntfs"
/dev/sda5: UUID="0f8b9c1d-9ce9-44e6-a95a-9c58299f1ca0" TYPE="ext4"
/dev/sda6: UUID="0ec1636e-27bb-4dd0-a035-0a46760ba247" TYPE="swap"
The /dev/sda1 / NTFS line is the one I am interested in. Then create a location to mount the partition:
$sudo mkdir /mnt/win
Then edit fstab using the text editor of choice eg leafpad:
$sudo leafpad /etc/fstab
Add the following line to fstab:
#Evil mount point
/dev/sda1 /mnt/win ntfs defaults 0 0
Finally, mount all partitions with:
$sudo mount -a
Check disk space
$df