When helping others solve problems, it's often handy to look at files of various types -- configurations, logs, etc. Sometimes copying and pasting files into replies here can be difficult, especially if the X windowing system isn't working or if the files are particularly long. Fortuntely, the Ubuntu repository contains a handy utility called pastebinit that reads a file, posts it to Ubuntu's pastebin, and returns the URL.
Install the utility:
To send a file to the pastebin, run the utility with the name of the file. For example:
If you need to send a file that only the root user can read, don't forget to use sudo. For example:
When you run pastebinit, the utility will output to the console the URL of the file. If you're using the tool to create a file you'd like someone on the forum to read, include that URL in your message.
Now here's a neat trick. Say you need to post several files, all in one subdirectory. You can a short command script for that. For example:
The command above reads each file in /var/log/lightdm, displays the name of the file on the screen, posts the file to the pastebin, and returns the URL. (I've used the LightDM logs in my example, thus the need for sudo.) Now, rather than copying the contents of each file into a message here, you can just copy and paste the brief output from running the script. Forum readers will see the file name and the neighboring URL and can view the contents of each file.
When pasting the output, don't enclose it in CODE tags. That way, the forum will interpret the URL as a real URL and allow it to be clicked. I'll run the above command on my own computer so you can see what I mean. (The numbers are made up; the files aren't actually from my PC.)
/var/log/lightdm/lightdm.log - http://paste.ubuntu.com/00000001/
/var/log/lightdm/x-0-greeter.log - http://paste.ubuntu.com/00000002/
/var/log/lightdm/x-0-greeter.log.old - http://paste.ubuntu.com/00000003/
/var/log/lightdm/x-0.log - http://paste.ubuntu.com/00000004/
Very handy.
Install the utility:
Code:
sudo apt-get install pastebinit
Code:
pastebinit /var/log/syslog
Code:
sudo pastebinit /var/log/fsck/checkroot
Now here's a neat trick. Say you need to post several files, all in one subdirectory. You can a short command script for that. For example:
Code:
for i in /var/log/lightdm/*; do echo -n "$i - "; sudo pastebinit $i; done
When pasting the output, don't enclose it in CODE tags. That way, the forum will interpret the URL as a real URL and allow it to be clicked. I'll run the above command on my own computer so you can see what I mean. (The numbers are made up; the files aren't actually from my PC.)
/var/log/lightdm/lightdm.log - http://paste.ubuntu.com/00000001/
/var/log/lightdm/x-0-greeter.log - http://paste.ubuntu.com/00000002/
/var/log/lightdm/x-0-greeter.log.old - http://paste.ubuntu.com/00000003/
/var/log/lightdm/x-0.log - http://paste.ubuntu.com/00000004/
Very handy.
Comment