aspell (command line spell checking)
- Spell check an input file:
aspell -c sample.texSpell check an input file (do not create backup file):
aspell -dont-backup -c sample.texShow personal dictionary (note: the first one does not work on Ubuntu, alternate provided):
aspell dump personal
sudo updatedb
locate .aspell*
cat ~/.aspell.en.pwsShow aspell configuration:
aspell dump configAdd a package:
sudo apt-get install package_nameRemove a package:
sudo apt-get remove package_nameAdd repository:
sudo apt-add-repository ppa:sample_ppa/sampleSearch packages:
sudo apt-get update
apt-cache search search_termList installed packages:
dpkg -lList files and directories of an installed package:
dpkg -L package_nameCopy a file:
cp /example/file1 /example/file2Copy a directory (dir1 into dir2):
cp -a /example/dir1 /example/dir2Move a file:
mv /example/file1 /example/file2Delete a file:
rm /example/file1Delete a directory (be careful):
rm -rf /example/dirList drives and partitions:
sudo fdisk -lClone a drive (note: drive /dev/sdb must have size greater than or equal to /dev/sda):
sudo dd if=/dev/sda of=/dev/sdbClone drive to a file (note: output file location should not be on any partition of /dev/sda):
sudo dd if=/dev/sda of=/home/sda_as_backup_fileReport progress (sends signal to dd every 10 seconds):
ps au | grep dd
sudo watch -n 10 "kill -USR1 processid"List partition UUIDs:
sudo blkidModify partition UUID (if ext2/3/4, device is e.g. /dev/sda1):
tune2fs -U random /dev/sda1Report usage for all mounted drives:
df -hShow sorted usage of directories at root:
sudo du -hsx /* | sort -nList files bigger than 100 MB:
find -size +100M -lsRecord desktop (at 24 fps, 1920x1080 resolution, on screen 0, using mpeg4):
ffmpeg -f x11grab -y -r 24 -s 1920x1080 -i :0+0,0 -vcodec mpeg4 -sameq sample_out.mp4Record desktop (400x400 portion of desktop at offset 200x200 on screen 1):
ffmpeg -f x11grab -y -r 24 -s 400x400 -i :1+200,200 -vcodec mpeg4 -sameq sample_out.mp4Record webcam/microphone:
ffmpeg -f alsa -ac 2 -i hw:0 -i /dev/video0 -acodec ac3 -ab 128k -vcodec mpeg4 -sameq -r 24 sample_out.mp4Transcode video (and resize):
ffmpeg -i sample.mp4 -sameq -s hd720 sample_720.mp4Transcode audio only:
ffmpeg -i sample.mp4 -vcodec copy -acodec aac -sameq sample_out.mp4Speed up video:
ffmpeg -i sample.mp4 -vf "setpts=0.05*PTS" -r 25 -s hd720 -sameq sample_out.mp4Rotate video 90 degrees clockwise:
ffmpeg -i sample.mp4 -vf "transpose=1" -sameq sample_out.mp4Rotate video 90 degrees counter-clockwise:
ffmpeg -i sample.mp4 -vf "transpose=2" -sameq sample_out.mp4Video overlay:
ffmpeg -i sample.mp4 -aspect 4:3 -vf "movie=overlay.png [logo]; [in][logo] overlay=0:0:1" -sameq sample_out.mp4Images to video:
ffmpeg -r 1 -i dgplogo%01d_1080.png -sameq sample_out.mp4Merge videos (not supported by all formats):
ffmpeg -i "concat:sample1.avi|sample2.avi" -vcodec copy -acodec copy sample_out.mp4Compile object file(s):
gcc -c sample.c -o sample.oCreate static library (.a):
ar crs libsample.a sample.oCreate shared library (.so):
gcc -shared -o libsample.so sample.oLinking a static library (creates executable program "test_static"):
gcc -static test.c -L. -lsample -o test_staticLinking a shared library (creates executable program "test_shared"):
gcc test.c -L. -lsample -o test_sharedAdd shared library path:
(General) Append path to /etc/ld.so.conf
(Ubuntu) Append path to /etc/ld.so.conf.d/.confUpdate shared library paths:
sudo ldconfigAdd shared library path temporarily to run executable:
#!/bin/bash
LD_LIBRARY_PATH=/directory/for/libs/:$LD_LIBRARY_PATH
echo 'looking for shared libraries here first' $LD_LIBRARY_PATH
/path/to/executableView shared libraries needed by executable, and paths to files linked at runtime:
ldd /path/to/executableOutput assembly code (extension is .s):
gcc -S -c sample.cConfigure username and email (globally), and set merge tool:
git config --global user.name "My Name"
git config --global user.email "example@email.ca"
git config merge.tool kdiff3Copy remote repository contents locally:
git clone https://github.com/Example/repo.gitAdd and show remote repository (call it "upstream"):
git remote add upstream https://github.com/Example/repo.git
git remote -vSee history of repository ("upstream"):
git log upstreamShow details of last commit:
git showShow remote branches (fetch updates local list):
git fetch
git branch -rShow local branches:
git branchDelete local branch:
git branch -D branch_nameAdd files to be committed:
git add /path/to/filesUpload all local changes to master branch of remote repository "origin":
git commit -a -m'made some changes'
git push origin masterMerge pull request:
git pull upstream masterStash local changes (to pull):
git stashMerge another branch to active branch (note this auto-commits):
git merge origin/some_branchShow merge conflicts:
git statusResolve merge conflicts:
git mergetoolRevert all local changes to previous commit:
git reset --hard commit_hash_valueCreate a new branch:
git branch new_branchSwitch to work on other branch:
git checkout new_branchSearch file for string:
grep search_string filenameOutput line numbers where search string is found:
grep -n search_string filenameDisplay filenames containing search string:
grep -l search_string filenames*Search:
locate 'search_term1 search_term2'Search (case insensitive):
locate -i search_termUpdate filesystem database:
sudo updatedbFind locations of program executable/source/documentation:
whereis program_nameLocate a command:
which program_nameView manual page:
man program_nameSearch manual pages for keyword:
man -k keyword
apropos keywordList mounted drives:
mountMount a device (SATA drive 1, /media/drivedir must exist):
sudo mkdir /media/drivedir
sudo mount /dev/sda1 /media/drivedirUnmount device:
sudo umount /media/drivedirBack up a directory:
rsync -av source_path dest_pathBack up a directory and exclude files/directories:
rsync -av --delete-excluded --ignore-errors --exclude=*.gvfs* --exclude='.local' source_path dest_pathCreating a backup script:
#!/bin/bash
echo "Backing up..."
# may want to mount drive for source/dest paths first here
rsync -av source_path dest_path
chmod 744 ./backup.shSet ownership of dest path (e.g. if new partition owned by 'root'):
chown james:james /media/james/Drive -RConnect to server using ssh:
ssh username@server_addressCreate public/private key (RSA):
ssh-keygen -t rsaList keys loaded:
ssh-add -lAdd a new key:
ssh-add /path/to/private_keyPrint key fingerprint:
ssh-keygen -lf /path/to/keyCreate archive of directory and compress:
tar -czvf file.tar.gz /path/to/compress/Extract archive:
tar -xvf file.tar.gzCompress single file:
gzip input_fileUncompress single file:
gunzip input_file.gz
On getting nvidia_experimental_310 to work:
I had issues getting the nvidia_experimental_310 package working. It turned out there was a "nvidia_experimental_310" entry in a file "/etc/modprobe.d/blacklist-local.conf" causing the trouble. How and why that got there I may never know. Commands I tried to track down this problem and my path to a solution:Show loaded modules (with 'nvidia' in name):
lsmod | grep nvidiaNot loaded. Show errors in X.org log:
cat /var/log/Xorg.0.log | grep '(EE)'Error found, suggests checking kernel log:
[ 10.865] (EE) NVIDIA: Failed to load the NVIDIA kernel module. Please check your
[ 10.865] (EE) NVIDIA: system's kernel log for additional error messages.
[ 10.865] (EE) Failed to load module "nvidia" (module-specific error, 0)
Show kernel log (and view in 'less'):
cat /var/log/kern.log | lessLast entry shows it trying to load nvidia module? Not very helpful unfortunately.
Show all nvidia kernel objects:
locate *.ko | grep nvidia...
/lib/modules/3.5.0-21-generic/updates/dkms/nvidia_experimental_310.ko
Existence of the kernel object for the current version of the kernel I'm running (uname -r) is encouraging as it means when installing the nvidia_experimental_310 package it compiled OK. Let's try to link it into the kernel again ourselves.
Load a module (in this case, 'nvidia_experimental_310'):
sudo modprobe nvidia_experimental_310modprobe: WARNING: Not loading blacklisted module nvidia_experimental_310
Blacklisted? Huh?
Search all blacklisted modules (whose name contains 'nvidia'):
cat /etc/modprobe.d/blacklist* | grep nvidiablacklist nvidiafb
blacklist nvidia_experimental_310
Aha! After removing blacklist-local.conf which contained the above entry, I tried again.
Load a module, then restart display manager:
sudo modprobe nvidia_experimental_310
sudo service restart lightdmWorking well!
copy/pasting into the terminal:
"Control-Shift-V" pastes text directly into the terminal, avoiding the need to right click and choose "Paste" each time.filesystem mounting options for a solid state drive:
You can edit "fstab" (the file system table) by doing the following:gksudo gedit /etc/fstabTo identify which is the SSD:
blkidListing all partition information can be helpful to identify the drive:
sudo fdisk -lUnder "options" in the fstab, for the SSD, adding discard adds TRIM support, adding noatime, nodiratime disables extra writes to keep track of when files and directories were last accessed. For instance if the SSD line in fstab is:
UUID=03f7d0a1-2fcb-4878-afef-8487799df4a4 / ext4 errors=remount-ro 0 1Change it to the following, using commas to separate each option:
UUID=03f7d0a1-2fcb-4878-afef-8487799df4a4 / ext4 discard,noatime,nodiratime,errors=remount-ro 0 1Do not forget to save and restart.
using udisks and gnome-session-properties to automount partitions on login:
The easiest way to set up automatic mounting is using the gnome-disks tool, and choosing "Edit mount options...". The next easiest way is by running gnome-session-properties and add the following command:/usr/bin/udisks --mount /dev/sdb1where "/dev/sdb1" the partition you wish to mount. Using a UUID is preferred in case drives get switched around, to view partition UUIDs use:
blkidGiven the UUID of the partition, change the udisks command parameters to:
/usr/bin/udisks --mount /dev/disk/by-uuid/1234567890ABCDOr, one can edit the filesystem table file (/etc/fstab).
changing file ownership on a USB drive not formatted to FAT32:
The drive will not allow you to write to it since you are not the owner of files on that filesystem (the root account is). Chances are, while FAT* does not support the concept of user ownership, the existing filesystem does (e.g. ext4), causing the problem. Use the "chown" command to change the ownership to your account. With the drive mounted, do:sudo chown james /media/james/kingston32gbThis changes the files mounted to /media/james/kingston32gb to be owned by user james. You will then be able to both read and write files to the device.
getting multi-monitor settings with nvidia-settings to stick after reboot:
I had an issue with three display devices having their positions reset every reboot (two standard monitors, plus an Oculus Rift). The Oculus Rift would always be reset to be positioned between the two monitors. Using nvidia-settings and saving to /etc/X11/xorg.conf never seemed to work. Bring up a terminal and run:gksudo nvidia-settingsSet the desired display configuration. Then, save xorg.conf configuration settings to:
/usr/share/X11/xorg.conf.d/xorg.confYou may notice when browsing the directory /usr/share/X11/xorg.conf.d/ that a file xorg.conf.backup was instead saved. You can copy or rename this file using gksudo nautilus using a GUI, or use the terminal command
cd /usr/share/X11/xorg.conf.d/
sudo cp xorg.conf.backup xorg.confOn restart, the monitor settings should be remembered! (Tested on Ubuntu 13.04.)
removing overlay-scrollbar from default Ubuntu installation:
The selection zone to bring up the overlay scrollbar I have issues with. It appears when the cursor is over the left side of the window edge, but is displayed on the right. When moving the cursor to the right to manipulate the control, it often disappears - I find this frustrating.Fortunately, it is easy to disable the "overlay scrollbars". On Ubuntu 12.04:
gsettings set org.gnome.desktop.interface ubuntu-overlay-scrollbars falseand to bring them back:
gsettings reset org.gnome.desktop.interface ubuntu-overlay-scrollbarsFor Ubuntu 12.10 and 13.04, to disable them:
gsettings set com.canonical.desktop.interface scrollbar-mode normaland to bring them back:
gsettings reset com.canonical.desktop.interface scrollbar-modeThe command should take effect immediately. Previously, I removed the package using "sudo apt-get remove overlay-scrollbar". While that worked, warnings would appear about the missing "overlay-scrollbar" GTK module when running applications.
fixing the fontconfig warning when running applications:
When running my Qt applications, under application output I would always see the message: Fontconfig warning: "/etc/fonts/conf.d/50-user.conf", line 9: reading configurations from ~/.fonts.conf is deprecated. This can be fixed by doing the following:mkdir ~/.config/fontconfig
mv ~/.fonts.conf ~/.config/fontconfig/fonts.confThe change should take effect immediately -- applications will no longer complain about it. (Tested on Ubuntu 13.04.)
setting up an environment for making documents with TeXworks and LaTeX:
On a new Ubuntu installation, to produce academic papers I install TeXworks software, the latexmk script, and some LaTeX packages, using the following:sudo apt-get install texworks latexmk texlive-latex-recommended texlive-latex-extraIn TeXworks, Edit>Preferences>Typesetting. Add latexmk processing tool with the program usr/bin/latexmk and the following command line arguments:
-e
$pdflatex=q/pdflatex $synctexoption %O %S/
$fullnameCheck "view PDF after running", press OK. For default - set to latexmk.
switching between qt4 and qt5 with qtchooser:
I reinstalled Ubuntu 13.04 on a machine (comes with qt4) overtop a 13.10 installation (comes with qt5). I found when building through qtcreator that there were errors in relation to using the qt5 libraries rather than qt4. The program "qmake" is a symlink to the program "qtchooser", which was configured to use qt5. To set it back to qt4, the /usr/share/default.conf symlink needs to point to qt4.conf:cd /usr/share/qtchooser
sudo rm default.conf
sudo ln -s qt4.conf default.conf
open a terminal through nautilus:
Use the following command to install the extension:sudo apt-get install nautilus-open-terminal
youtube issues with chromium:
On an Ubuntu 12.04 installation with chromium, youtube videos often fail to load with the message "This video is currently unavailable". The fix (in my case):sudo apt-get remove chromium-codecs-ffmpeg
sudo apt-get install chromium-codecs-ffmpeg-extra
hostnames, avahi and .local:
You may find you are unable to connect using the hostname to another computer on the network (e.g. for a computer whose hostname is "whirringbox"):ping whirringbox
ping: unknown host whirringboxUbuntu (and others) include software called avahi, "zero-configuration networking software" which includes support for something called mDNS (or the "multicast Domain Name System"). On Ubuntu installations, there will be a program called avahi-daemon running. For example, if we run on whirringbox:
ps -ax | grep avahithis displays
684 ? S 0:00 avahi-daemon: running [whirringbox.local]
687 ? S 0:00 avahi-daemon: chroot helper
8350 pts/0 S+ 0:00 grep --color=auto avahiThe purpose of the avahi-daemon process is to make the computer accessible on the local network. Supporting mDNS, avahi-daemon waits for a message on the local network requesting the host with name "whirringbox.local" to identify itself. Then, the avahi-daemon replies to this message, providing the IP address of whirringbox. So in general, to connect to an Ubuntu machine by hostname for an mDNS-supporting system, you need to add ".local":
ping whirringbox.local
PING whirringbox.local (192.168.0.11) 56(84) bytes of data.
64 bytes from whirringbox.local (192.168.0.11): icmp_req=1 ttl=64 time=0.543 ms
64 bytes from whirringbox.local (192.168.0.11): icmp_req=2 ttl=64 time=0.150 ms
64 bytes from whirringbox.local (192.168.0.11): icmp_req=3 ttl=64 time=0.152 msI find this a great alternative to the idea of setting up static IP addresses and messing with /etc/hosts.
linker errors using webkitwidgets:
When attempting to add a webpage viewer to my Linux Qt5 application (Ubuntu 14.04) via a "QWebView", part of the "webkitwidgets" module (QT += webkitwidgets), I was missing some development libraries which were causing numerous linker errors (libraries which could not be found). Many related to gstreamer, but there were a few others. Installing the following few packages fixed this for me:sudo apt-get install libgstreamer0.10-dev
sudo apt-get install libxslt-dev
sudo apt-get install libgstreamer-plugins-base0.10-dev
convert a PDF into a series of images:
Use the command line utility pdftoppm:pdftoppm -png slides.pdf slide_imgs/slidewhere -png defines the format (e.g. png, jpg) can be specified, slides.pdf is the input file, and slide_imgs/slide is the prefix for each filename (this puts slides into a slide_imgs subdirectory).
remove cached startup errors:
You may encounter some startup errors with a dialog saying "system program problem detected", even if nothing is actually wrong. These may be caused by errors that occurred long ago that have been not been cleared properly. To do this manually, use the following:sudo rm /var/crash/*If you still have startup error dialogs after doing this, check the contents of the /var/crash directory.
No comments :
Post a Comment