If your Linux is using LVM (Logical Volume Management) testing out or setting up can be much safer if you take a snapshot of your root partition. Here's a small but helpful example to help you do this quickly.
Showing posts with label script. Show all posts
Showing posts with label script. Show all posts
Friday, March 13, 2015
Friday, March 7, 2014
Cleaning out linux-image-x.x.xx-xx-* files
I was suddenly denied access to my in-house web-server with a message telling me the disk is full. After a quick check with df -h I could confirm the root partition used 100%.
First I started to look for "user -files" I could remove, but found out there wasn't all that many of them. Most of the usage was in the folders /lib, /usr and /var. A quick question to my friend google took me in the direction that there could be some linux-image files no longer used that were spending my disk.
Some more searching gave me the following solution to removing these unused kernel files:
First I started to look for "user -files" I could remove, but found out there wasn't all that many of them. Most of the usage was in the folders /lib, /usr and /var. A quick question to my friend google took me in the direction that there could be some linux-image files no longer used that were spending my disk.
Some more searching gave me the following solution to removing these unused kernel files:
Tuesday, December 11, 2012
find files between two dates
Here's a quick tip for how you can find a file between two dates.
Suppose you are looking for a file you know you worked with last friday. At the time of writing this would be on december 7th. Using the find command you can go to your terminal and add the following code:
This would search for files acessed between dec. 7th and dec. 8th.
This code snippet also shows an example of how to use the -newerXY parameter of the find -command.
Suppose you are looking for a file you know you worked with last friday. At the time of writing this would be on december 7th. Using the find command you can go to your terminal and add the following code:
find . -type f -newerat "2012-12-07" -not -newerat "2012-12-08"
This would search for files acessed between dec. 7th and dec. 8th.
This code snippet also shows an example of how to use the -newerXY parameter of the find -command.
Sunday, September 30, 2012
Scaling a pdf file from A3 to A4
This is just a quick tip for converting a pdf file from one pagesize to another.
By using the command convert this is easily achieved.
This is the quickest way I've found to do this:
The outfile.pdf should now be sized as an A4 page.
The command is as follows: convert [input file options] infile.pdf [output file options] outfile.pdf
Of course it is possible to convert to and from other sizes as well.
By using the command convert this is easily achieved.
This is the quickest way I've found to do this:
convert -page a3 infile.pdf -page a4 outfile.pdf
The outfile.pdf should now be sized as an A4 page.
The command is as follows: convert [input file options] infile.pdf [output file options] outfile.pdf
Of course it is possible to convert to and from other sizes as well.
Sunday, September 23, 2012
SSH without password prompting
Usually while working on different computers I am using SSH. Being prompted for a password is not a favourite of mine, so I set up my computers to connect without needing a password. It's easier than you think.
Thursday, August 16, 2012
Password prompt via ssh
Sometimes when working with ssh you want to run a command that require root privileges on the remote host.
For instance when running apt-get install.
The trick is then to add the -t option to ssh so you get to write the remote host password.
Like this:
Without the -t option you would get the following error:
For instance when running apt-get install.
The trick is then to add the -t option to ssh so you get to write the remote host password.
Like this:
ssh -t example.com "sudo apt-get install nmap"
Without the -t option you would get the following error:
sudo: no tty present and no askpass program specified
Saturday, August 11, 2012
Making an A5 book from a pdf-file
Here's how to create an A5 book from a pdf file. This procedure can be done by creating a script that runs through the needed steps automatically. I'll see if I will do that later. But here is the necessary steps to do this manually.
The mission is to print a folder on A4 paper, and fold it into a book.
After we have printed the book; the pages should come sequentially as in all books. Fold, staple and deliever you brochure/folder. If the original document is more than 4-5 pages we might want to cut a little in front of the book after we have folded it.
The mission is to print a folder on A4 paper, and fold it into a book.
- Calculate: (number of pages \ 4) + 1 = Sheets (This is needed as the -s parameter in the psbook-command. If the original document has 9 pages then we need to use the following calculation: (9 \ 4)+1 = 2 + 1 = 3) 2 sheets will hold 8 pages which is one page less than the document. 3 sheets will hold 12 pages and is more than the document.
- Convert the original file to a .ps-file: pdftops original.pdf new_original.ps
- Create the pages in the book: psbook -s3 new_original.ps new_original_book.ps (Refer to step 1 for info about -s3 parameter)
- Reorder the pages using psnup: psnup -l -n2 new_original_book.ps new_original_folder.ps (Parameter -l is to print in landscape, and -n2 is to place 2 pages on each page.)
- Convert back to pdf-format: ps2pdf new_original_folder.ps folder.pdf
- Remove temporary files: rm new_original_*
After we have printed the book; the pages should come sequentially as in all books. Fold, staple and deliever you brochure/folder. If the original document is more than 4-5 pages we might want to cut a little in front of the book after we have folded it.
Wednesday, July 18, 2012
Next AUTO_INCREMENT number in mySQL
Here's a quick little tip if you are going to add a new item in a mySQL table and would like to know the next AUTO_INCREMENT value.
Simply query the mySQL-server for the next value in your table like this:
Replace <DB_NAME> and <TABLE_NAME> with the appropriate DB-schema and table name on your own mySQL server.
Simply query the mySQL-server for the next value in your table like this:
SELECT AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA='<DB_NAME>' AND TABLE_NAME='<TABLE_NAME>
Replace <DB_NAME> and <TABLE_NAME> with the appropriate DB-schema and table name on your own mySQL server.
Subscribe to:
Posts (Atom)