Commands using mkswap (2)

  • Create a temporary file that acts as swap space. In this example it's a 1GB file at the root of the file system. This additional capacity is added to the existing swap space. Show Sample Output

    sudo dd if=/dev/zero of=/swapfile bs=1024 count=1024000;sudo mkswap /swapfile; sudo swapon /swapfile
    dcabanis · 2009-05-27 21:10:50 1
  • In addition to a swap partition, Linux can also use a swap file. Some programs, like g++, can use huge amounts of virtual memory, requiring the temporary creation of extra space.

    dd if=/dev/zero of=/swapfile bs=1M count=64; chmod 600 /swapfile; mkswap /swapfile; swapon /swapfile
    starchox · 2009-02-16 18:36:38 0

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Check These Out

Nicely display mem usage with ps
Nicely display mem usage with ps.

Files extension change
Changing a file extension to a new one for all files in a directory.

Capture screen and mic input using FFmpeg and ALSA
Yet another x11grab using ffmpeg. I also added mic input to the capturing video stream using alsa. Yet I need to find out how to capture audio which is currently playing.

check open ports without netstat or lsof

for all flv files in a dir, grab the first frame and make a jpg.
This is handy for making screenshots of all your videos for referring to in your flv player.

Check if you partition are aligned
To get most of you HDD/SSD driver you need to make sure you partition are aligned, if not the speed penalty can be up to 50% slower! this simple one liner will check to see if each partition start sector is divided by 512 you need to change sda with your driver if you find the one of your partitions is not aligned use gparted to move the start sector of the partition to be divided of 512

Renames all files in the current directory such that the new file contains no space characters.
This is a better version, as it does no command piping, uses for instead of while loops, which allows for a list of files in the current working directory to be natively processed. It also uses the -v/verbose option with mv to let you know what the command is doing. While the command does exactly the same in a better way, I would modify the sed option to replace spaces with underscores instead, or dashes. Please note that you'll receive errors with this command as it tries to rename files that don't even have spaces. This is an alternative to:

sort lines by length

Turn shell tracing and verbosity (set -xv) on/off with 1 command!
Running this command turns shell tracing and shell verbose debugging on or off. Not only does it do that, it also uses your terminals builtin method of setting colors to make debugging much easier. It looks at the current shell options contained in the $- special bash variable and that lets this function set the opposite of the current value. So from the shell you could do a: $ setx; echo "y" | ( cat -t ) | echo "d"; setx and it will turn on debbuggin. This is an amazingly useful function that is perfect to add system-wide by adding it to /etc/profile or /etc/bashrc.. You can run it from the shell, and you can also use it in your shell scripts like my .bash_profile -

return a titlecased version of the string
Needs Bash4. Found at alongside a few other tricks.

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: