Posts

Showing posts with the label bash

Copying files from remote to localhost

Just for Linux Remote host to localhost: username@remotehost.com:file /local_directory/  From localhost to Remote host scp file username@remotehost.com:/remote_directory/ 

Cleaning Bash History...

Just run: cat / dev / null > ~/. bash_history && history - c && exit

Install compass in Mac Os El Capitan

So, $ sudo gem install compass is not working? Do you have ruby installed? If not install it using brew: $ sudo brew install ruby  First try updating your gem version: $ sudo gem update --system Then try again installing compass: $ sudo gem install compass Oh... now you get a: Fetching: compass-1.0.3.gem (100%) ERROR:  While executing gem ... (Errno::EPERM)     Operation not permitted - /usr/bin/compass Run the following: $ sudo gem install -n /usr/local/bin compass Done.

Combine two (or more) images in one using convert in command line

I you want to combine two or more images in one you can try using command convert . This program is member of the ImageMagick(1) suite of tools.  In my case, its already installed in my bash term, so i didn't install anything. If you want more information about this command you can go to ImageMagick site or just type man convert in bash How to use it: convert img1.jpg img2.jpg [img3.jpg ... imgN] +append new_img.jpg convert img1.jpg img2.jpg [img3.jpg ... imgN] -append new_img.jpg The + will append images  horizontally and the - vertically.

Using wget to download a page and browse it locally

Run:  [carpincho@bender]$ wget -r --convert-links url What the arguments do: -r (its the same using --recursive)   Turn on recursive retrieving.   The default maximum depth is 5. -k (its the same using --convert-links) After the download is complete, convert the links in the document to make them suitable for local viewing. This affects not only the visible hyperlinks, but any part of the document that links to external content, such as embedded images, links to style sheets, hyperlinks to non-HTML content, etc. url (obvious :P) Note: You can run it under any Unix based Os or under Mac Os previouly installing it with macports

Counting a project line of codes with Console

find . -name "*.py" -print0 | xargs -0 wc -l For the actual repo ninja-ide (pull date: 21/11/11), its   17121 LoC Ninja-IDE (pull date: 27/10/11), 16562 LoC

Show hidden files in Mac Os Lion

Open Terminal and run: $ defaults write com.apple.Finder AppleShowAllFiles YES Relaunch Finder (hold alt key and right click on Finder, then Relaunch) To hide this files again run in Terminal: $ defaults write com.apple.Finder AppleShowAllFiles NO and also relaunch Finder as above. source

Delete all the "Thumbs.db" files - Mac Os Lion

First, find out how many of them you have, by running this command: find . -iname "Thumbs.db" And just run the following command in the base folder from where to erase them: find . -iname "Thumbs.db" -delete source

Extract audio (in mp3 format) from a .flv file - Ubuntu 11.04

Open a console and run: sudo apt-get install ffmpeg libavcodec-extra-52 ffmpeg -i file.flv -ar 44100 -ab 160 -ac 2 audio.mp3

Fix file permissions in Mac OS X

A few days ago I copied a bunch of files/folders from an external NTFS formatted hard drive to my MacBook. The files where copied ok, but the permissions where messed up. How did I fix them? With this simple command: $ chmod -Rv u=rwx,g=rx,o=r username path_to_base_folder It recursively goes through all files and folders and fix their permissions. Source!

Creating Iso files from directories

mkisofs -o name.iso directory

How to remove/install/reconfigure xorg without reinstalling ubuntu

Open terminal Remove existing xorg using the following command sudo apt-get remove --purge xserver-xorg Install xorg using the following command sudo apt-get install xserver-xorg Reconfigure xorg using the following command sudo dpkg-reconfigure xserver-xorg source: title link

Resize images from Console

convert name.jpg -resize 50% name.png

How to use find command

On Debian based distros, find is part of the package findutils . find allow one to search for files on a filesystem based on different condition, creation date, modified date, file size, file type, permissions, name .... This tutorial, will be focused on finding files/directories based on their name, in order to explain in more depth the syntax of find, also will show how you can narrow down your search by adding condition on size and file modification time. 1. Find basis The default syntax of find is as such: find [path] [expression] where path is the path used as root for searching pattern and expression the expression we want the file to match. 2. Finding a file based on filename Let say for instance you want to find all .avi files in users home directories. Search files can be found with the following command: # find /home -name '*.avi' If you want to search for *.mpg and *.avi files, you will use the following: find /home -name '*.mpg' -o -name '*....

sudo: port: command not found

If you install mac ports under Mac, then run sudo port install "app_here"  and you recieve this error (the title), i have the solution. One word. $PATH. Open your .bashrc file (if you dont have it, create it), and add these lines export PATH=/opt/local/bin:/opt/local/sbin/:$PATH export MANPATH=/opt/local/share/man:$MANPATH (the first, for the port command and the second for the manpages of port command. Yea, i know its obvious... :P) Ciao!

Como escuchar la rock and pop desde Ubuntu

La opción mas conocida es bajarse el plugin para firefox de moonlight ... (cosa que hice y no me funcionó)... La segunda opción es, instalar mplayer y en terminal cargar la direccion con mplayer.  ie: mplayer mmsh:// streaming.fmroc kandpop.com/roc kandpop?MSWMExt =.asf (gracias darĆ­o que me pasó la solución! me cago en ms!) Chupate esta mandarina MS!! :D Sino desde Vlc desde este post Update(7/3/12) La nueva url es: mmsh://200.89.168.10:80/audio959-rockandpop?MSWMExt=.asf

Copy files with cp (fancy way)

Copy files from dir A to dir B. (cause i always forget wh ich are the proper flags...) cp -Rpnv "Dir_A" "Dir_b" n : Do not overwrite an existing file (overides -f flag). p : Preserves attributes for each source file. R : Files are copied recursively. v : Show files while copying them.

Comandos mas usados

carpincho@optimus:~$ history|awk '{print $2}'|awk 'BEGIN {FS="|"} {print $1}'|sort|uniq -c|sort -rn|head -10