Once you learn the magic :q! combination to close Vim discarding changes, you find out that it is a quite powerful tool.
To remove empty lines from a file you might try with some specific commands such as:
:g/^$/d
Where g tells vim to execute a command only on the lines that match a regular expression, ^$ is said regular expression to match empty (blank) lines, and d is the delete command.
Bonus: if when you open the file you see a lot of ^M characters, it means you're editing it in Unix format but the file was created in DOS format. You can either try by telling vim to treat it as a DOS format before running the previous instruction:
:set ff=dos
or by converting the file to Unix format beforehand with the dos2unix command:
dos2unix -n in out
17/01/2015
[Yum] Prevent packages from being installed or updated
Even though it is recommended to always run the latest software version for bug fixes and security purposes, sometimes the package maintainers might have gotten too many donations and slip up on the next release.
And if that release is a kernel release, things might get ugly. Luckily, you can prevent yum from installing or updating packages by adding the --exclude parameter to your commands:
yum --exclude=PACKAGE update
this will update the system but not the packages named PACKAGE. Its scope is limited to the single command, so a second yum update will not exclude them.
Eg to exclude kernel packages:
yum --exclude=kernel* update
To make the exclusion permanent, edit /etc/yum.conf and add a line:
exclude=PACKAGE
And if that release is a kernel release, things might get ugly. Luckily, you can prevent yum from installing or updating packages by adding the --exclude parameter to your commands:
yum --exclude=PACKAGE update
this will update the system but not the packages named PACKAGE. Its scope is limited to the single command, so a second yum update will not exclude them.
Eg to exclude kernel packages:
yum --exclude=kernel* update
To make the exclusion permanent, edit /etc/yum.conf and add a line:
exclude=PACKAGE
[Linux] Test RPM dependencies and installation without altering the system
So you already know how to do this with APT, but what if you're using an RPM-based distro?
Easily enough:
repoquery --requires --recursive --resolve PACKAGE_NAME
will check and list the package dependencies and:
rpm -ivh --test PACKAGE_NAME
will run a dry install which will show you what changes would take place without actually installing anything
Easily enough:
repoquery --requires --recursive --resolve PACKAGE_NAME
will check and list the package dependencies and:
rpm -ivh --test PACKAGE_NAME
will run a dry install which will show you what changes would take place without actually installing anything
[Fedora] VLC repository
In order to install VLC on Fedora, you'll need to add their repository to your sources.
Simply:
yum install --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
yum install vlc
If you find that you cannot play some media types, try installing these gstreamer plugins as well
yum install gstreamer-plugins-good gstreamer-plugins-bad gstreamer-plugins-ugly
Simply:
yum install --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
yum install vlc
If you find that you cannot play some media types, try installing these gstreamer plugins as well
yum install gstreamer-plugins-good gstreamer-plugins-bad gstreamer-plugins-ugly
[Yum] Add and manage custom repositories
In the latest Fedora versions, it is possible to add custom repositories to yum by creating a .repo file under the /etc/yum.repos.d/ folder following this structure:
[REPOSITORY_NAME]
baseurl=REPOSITORY_URL
enabled=1
gpgcheck=1
gpgkey=URL_TO_KEY
This will add and enable the repo available at REPOSITORY_URL signed by the GPG key found at URL_TO_KEY to your list.
Here's a couple of offical Fedora repos for Google Chrome and VirtualBox:
[REPOSITORY_NAME]
baseurl=REPOSITORY_URL
enabled=1
gpgcheck=1
gpgkey=URL_TO_KEY
This will add and enable the repo available at REPOSITORY_URL signed by the GPG key found at URL_TO_KEY to your list.
Here's a couple of offical Fedora repos for Google Chrome and VirtualBox:
[Yum] Fix rpmdb open failed error
Although not as good as other package managers, yum has come a long way since I last tried it.
However, due to me installing software using the rpm command and other graphical package managers (it is bad, seriously), I managed to screw up something causing it to complain with a "rpmdb open failed" error.
The fix is easy enough though:
rm -rf /var/lib/rpm/__db*
rpm --rebuilddb
yum clean all
yum update
However, due to me installing software using the rpm command and other graphical package managers (it is bad, seriously), I managed to screw up something causing it to complain with a "rpmdb open failed" error.
The fix is easy enough though:
rm -rf /var/lib/rpm/__db*
rpm --rebuilddb
yum clean all
yum update
[Fedora] [Gnome] Use delete key to delete files
For some reason, on Fedora 21 - and possibly earlier versions too - you're required to Ctrl + Delete to send a file to the trash instead of the plain old single key Delete.
This behaviour can be reverted back to the good old ways by editing the accels file under /home/USER/.config/nautilus/
Find the line:
and edit it to:
now if you log out and in again you're set.
This behaviour can be reverted back to the good old ways by editing the accels file under /home/USER/.config/nautilus/
Find the line:
;(gtk_accel_path "<Actions>/DirViewActions/Trash" "<Primary>Delete")
and edit it to:
(gtk_accel_path "<Actions>/DirViewActions/Trash" "Delete")
now if you log out and in again you're set.
[Eclipse] [ApacheDS] Crash soup_session_feature_detach on startup
Older Eclipse versions might incur in the 968064 bug - note that there exists multiple reports of that for other distros as well - which prevents the application from starting up.
Upgrading to a newer version should fix the issue but there's a simple workaround. Just add in the eclipse.ini file this parameter to the JVM options:
-Dorg.eclipse.swt.browser.DefaultType=mozilla
If using ApacheDS, the fix can be applied to the config/config.ini file by adding this line anywhere:
org.eclipse.swt.browser.DefaultType=mozilla
Upgrading to a newer version should fix the issue but there's a simple workaround. Just add in the eclipse.ini file this parameter to the JVM options:
-Dorg.eclipse.swt.browser.DefaultType=mozilla
If using ApacheDS, the fix can be applied to the config/config.ini file by adding this line anywhere:
org.eclipse.swt.browser.DefaultType=mozilla
[Linux] Compress and split file or directory
On Linux, it is possible to compress anything and split the resulting archive with the split command
split -b SIZE - FILENAME_
Note that the trailing underscore _ isn't required but helps organizing the file names.
For example, to create an archive with tar and chunk it in 1KB pieces:
tar cz myFile | split -b 1KiB - out.tgz_
To decompress it, simply recreate the file with cat first:
cat FILENAME_* | tar xz
es:
cat out.tgz_* | tar xz
split -b SIZE - FILENAME_
Note that the trailing underscore _ isn't required but helps organizing the file names.
For example, to create an archive with tar and chunk it in 1KB pieces:
tar cz myFile | split -b 1KiB - out.tgz_
To decompress it, simply recreate the file with cat first:
cat FILENAME_* | tar xz
es:
cat out.tgz_* | tar xz
Subscribe to:
Posts (Atom)