Author

The Archives

  • 11.27.09
    Ignoring an alias cmd, shell | rafacas | (3)
    Sometimes I want to ignore an alias. That might seem to make no sense because one of the reasons (the reason?) to use an alias (like ls='ls --color') is creating shortcuts. But, in some cases I need to use the real command, with its real output. In my case, it is because I share the same username with other people on some systems (yes, it is pretty awful, but that is another issue). To do this, precede the command with a backslash: '\'. For example: $ \ls Update: As loood has said in the comments, typing the command in quotes has the same ...
  • 11.25.09
    Comparing directories in local or remote hosts shell | rafacas | (0)
    I frequently need to compare two directories (with similar structures) to find different or new files. When I have to compare them locally, I use the diff command. $ ls test* test: file1 file2 file3 file4 file5 test.new: file1 file2 file3 file4 file5 file6 $ diff -qr test test.new Files test/file2 and test.new/file2 differ Files test/file4 and test.new/file4 differ Only in test.new: file6 The -q option tells diff to tell only whether the files differ and the -r option is for recursively comparing inside subdirectories. A more complicated problem arises when the comparation has to be done remotely, that is one of the directories is in another host (Samba, NFS, etc ...
  • 09.25.09
    Creating RSA keys security | rafacas | (0)
    RSA is an algorithm for public-key cryptography. Its advantage is that it does not require the initial exchange of secret keys unlike symmetric key algorithms. Each user has a pair of keys, one for encryption (the public key) and another one for decryption (the private key). The private key is kept in secret while the public key may be widely distributed. OpenSSL is usually the tool used for creating an RSA key pair (the public and private ones). $ openssl genrsa -out key.pem 1024 Generating RSA private key, 1024 bit long modulus ............................................++++++ .....++++++ e is 65537 (0x10001) This command creates a 1024-bit key pair and ...
  • 09.22.09
    Listing all service status cmd, shell | rafacas | (0)
    # service --status-all anacron (pid 2435) is running... atd (pid 2405) is running... auditd (pid 1777) is running... Avahi daemon is running cpuspeed is stopped crond (pid 2385) is running... cupsd (pid 2424) is running... dnsmasq is stopped hald (pid 2129) is running... httpd is stopped [...] Runs all init scripts (located in /etc/init.d), in alphabetical order, with the status option. Note: Only in Red Hat and redhat-like distros (Fedora, Mandriva,...).
  • 09.06.09
    How to verify MD5 or SHA-1 digests security | rafacas | (2)
    MD5 and SHA-1 are cryptographic hash functions. They are deterministic procedures that take an arbitrary block of data as input and return a fixed-size bit string, the hash value (called message digest or fingerprint as well). Verifying MD5 or SHA-1 digest is highly recommended when you download new software for your system. In most of Linux distros the md5sum and sha1sum commands are available: $ md5sum ubuntu-9.04-desktop-i386.iso 66fa77789c7b8ff63130e5d5a272d67b ubuntu-9.04-desktop-i386.iso $ sha1sum ubuntu-9.04-desktop-i386.iso 19aabf327fdbde9e66db54dc04e3a83b92f70280 ubuntu-9.04-desktop-i386.iso Solaris (even version 10) doesn’t ship either with md5sum or sha1sum installed. However you can use digest: % /usr/bin/digest -a md5 GNUgcc.3.4.4.SPARC.64bit.Solaris.10.pkg.tgz 498c344fe2839631bb7cf4b869b7b830 % /usr/bin/digest -a sha1 GNUgcc.3.4.4.SPARC.64bit.Solaris.10.pkg.tgz a8da8247900dd06a7000fd0e6d41f834d6ab3e40 And in Mac OS X, ...
  • 09.03.09
    Refreshing bash configuration cmd, shell | rafacas | (0)
    After writting some changes in the .bashrc file, you can reload it running this command: $ source ~/.bashrc or the even simpler $ . ~/.bashrc
  • 07.13.09
    OR in grep cmd | rafacas | (0)
    $ egrep "regexp1|regexp2" file1 file2 Search one or more files (file1 and file2 in our example) for lines that match any of several (two in our case) regular expressions: regexp1 OR regexp2. The '|' stands for the OR.
  • 07.10.09
    Adding password protection on a file with vim cmd, security | rafacas | (2)
    $ vim -x filename The -x option uses encryption when writing the file. It will ask for a key: Enter encryption key: ****** Enter same key again: ****** From then on your filename will be encrypted and accessed using the password. The -x option will no longer be necessary when editing the file.
  • 05.18.09
    Vi: emptying a file in one shot cmd | rafacas | (2)
    :1,$d This vi command blanks out the file being edited. Updated: javisantana suggested another way to emptying a file. Type: ggdG in command mode.
  • 05.14.09
    Split a file shell | rafacas | (0)
    Sometimes you need split a file. For example, to send them attached to an email. For this, you can use the split command. $ split -b 1m big_file file_part_ In the example, the big_file size is 10MB, the -b option split the file in 1MB pieces, and the file_part_ is the name given to the different parts. $ ls file_part_* file_part_aa file_part_ac file_part_ae file_part_ag file_part_ai file_part_ab file_part_ad file_part_af file_part_ah file_part_aj All the files are 1MB long. For joining all the parts you can ...