Showing posts with label shell. Show all posts
Showing posts with label shell. Show all posts

October 20, 2013

[SOLVED]grub rescue

After unfortunate partition deletion/recovery I landed in "grub rescue" prompt

This helped me to get into ubuntu and repair the

#list your partitions
ls


#try to list contents of your linux partition and finding grub folder
ls (hd0,msdos3)/boot/grub


#use this partition
set prefix=(hd0,msdos3)/boot/grub


#set mod
insmod normal


#boot
normal

December 3, 2012

[SOLVED] Linux: resize all images via console

Just install ImageMagick if you dont have it yet

sudo apt-get install imagemagick

Resize all JPG files in to desired size

mogrify -resize 640x480 *.jpg

Source: http://www.baptiste-wicht.com/2010/09/tip-batch-resize-images-on-ubuntu-linux/

September 5, 2012

[SOLVED] Hibernating your ubuntu via console

Just run this in console:
sudo /usr/sbin/pm-hibernate


For locking your session and hibernating just run:
gnome-screensaver-command -l && sudo /usr/sbin/pm-hibernate

August 23, 2012

[SOLVED] Fix permissons in linux

Just do:

to fix files permissions
find . -type f -exec chmod 644 {} \;

to fix folders permissions
find . -type d -exec chmod 755 {} \;

May 29, 2011

[SOLVED] Mount the remote file system on your local machine with sshfs

You can mount the remote file system on your local machine with sshfs:
mkdir -p /mnt/sshfs 
root@IS1300:~# sshfs 192.168.1.2:/ /mnt/sshfs 
root@IS1300:~# umount /mnt/sshfs

Then you can copy paste the file with nautilus/gnome/konqueror/dolphin/bash/whatever

 

Source: stackexchange.com

January 4, 2011

[SOLVED] Share log via Browser

This guide assumes you have a remote server, called loghost.example.org that you are going to use to avoid any firewall issues.

First make sure you have netcat-openbsd and NOT netcat traditional installed.
sudo apt-get install netcat-openbsd

Then to ensure your system is working try the following basic netcat tip.

Now to share my logging output I run on my laptop:
tail -f /var/log/syslog | ssh loghost "nc -v -l 8000"

Now to share my log with a remote collegue, he simply runs:
curl http://loghost.example.org.org:8000

or http://loghost.example.org:8000 in a browser

Source: dabase.com

January 3, 2011

[SOLVED]Building CSS sprites with Bash & Imagemagick

If you want to automatically generate image sprites - css file just use this script
$ spriteit.sh button button '*.png'

Output:
Generating sprite file...
executing: convert button_disabled.png button_hover.png button.png button_selected.png -append button/button-sprite.png
Sprite complete! - Creating css & test output...
#1 done
#2 done
#3 done
#4 done

Complete! - 4 sprites created, css written & test page output.

Script source:
#!/bin/bash

# uses imagemagick to stich together all images in a folder and
# then writes a css file with the correct offsets along with a
# test html page for verification that its all good

if [ $# -gt 0 ]
then

if [ 'x' != 'x'$4 ]
then
ext2=.$4; # the extension to iterate over for input files
else
ext2=".png"; # the extension to iterate over for input files
fi

if [ 'x' != 'x'$3 ]
then
#ext="."$3; # the extension to iterate over for input files
ext=$3; # the extension to iterate over for input files
else
ext=".gif"; # the extension to iterate over for input files
fi

name=$1; # output will be placed in a folder named this

if [ $2 ]
then
classname=$2"-sprite";
else
classname=$1"-sprite";
fi
css="$name/$classname.css";
html="$name/test.html";

rm -fr $name;
mkdir $name;
touch $css $html;

echo "Generating sprite file...";
#echo convert *$ext -append $name/$classname$ext;
echo executing: convert $ext -append $name/$classname$ext2;
convert $ext -append $name/$classname$ext2;

echo "Sprite complete! - Creating css & test output...";

echo -e "<html>\n<head>\n\t<link rel=\"stylesheet\" href=\"`basename $css`\" />\n</head>\n<body>\n\t<h1>Sprite test page</h1>\n" >> $html

echo -e ".$classname {\n\tbackground:url('$classname$ext2') no-repeat top left; display:inline-block;\n}" >> $css;
counter=0;
offset=0;
for file in $ext
do
width=`identify -format "%[fx:w]" "$file"`;
height=`identify -format "%[fx:h]" "$file"`;
#idname=`basename "$file" $ext`;
idname=`basename "$file" $ext2`;

clean=${idname// /-}
echo ".$classname#$clean {" >> $css;
echo -e "\tbackground-position:0 -${offset}px;" >> $css;
echo -e "\twidth: ${width}px;" >> $css;
echo -e "\theight: ${height}px;\n}" >> $css;

echo -e "<a href=\"#\" class=\"$classname\" id=\"$clean\"></a>\n" >> $html;

let offset+=$height;
let counter+=1;
echo -e "\t#$counter done";
done

echo -e "<h2>Full sprite:</h2>\n<img src=\"$classname$ext2\" border=1/>" >> $html;
echo -e "</body>\n</html>" >> $html;

echo -e "\nComplete! - $counter sprites created, css written & test page output. @russenreaktor";

else

echo -e "There should be at least 1 argument!\n\tbuildSprite.sh output_folder classname input_pattern"
echo -e "\n\tbuildSprite.sh folder1 test '*.png' png"

fi

Source: jaymz.eu

December 26, 2010

December 14, 2010

[SOLVED] Unix: search files between TIME1 and TIME2 with string 123456 in it

e.g.

TIME1 = 2010-11-02 00:00
TIME2 = 2010-11-24 00:00
SEARCHSTRING= 123456
File pattern "PATTERN1231313123.txt"

create files with right timestamps
 touch -t 11020000 /tmp/stamp_2010-11-02_0000
touch -t 11240000 /tmp/stamp_2010-11-24_0000

check your list of files if it is right
find . -regextype posix-awk  -regex '^\./PREFIX[0-9]*.txt' -newer /tmp/stamp_2010-11-02_0000 -and -not -newer /tmp/stamp_2010-11-24_0000 -ls

export your list
 find . -regextype posix-awk  -regex '^\./PREFIX[0-9]*.txt' -newer /tmp/stamp_2010-11-02_0000 -and -not -newer /tmp/stamp_2010-11-24_0000 -exec grep --color "123456" {} \; > /tmp/mydata_123456.csv

Source: serverfault.com, gnu.org