linux poison RSS
linux poison Email
0

Using GPG

1. Key Generation

gpg # Initialize GPG for this user (e.g. create ~/.gnupg). Only have to run once.
gpg --gen-key # Start key generation process. Follow prompts.

2. Viewing Keys

gpg --list-keys # View public keys
gpg --list-secret-keys # View private keys

3. Exporting Public Keys

gpg --export # Exports key in binary format
gpg --export --armor # Export in a usable, ASCII format

4. Importing Public Keys

gpg --import /path/to/public/key/file

5. Encrypting a Message

gpg --encrypt --armor --recipient message_file

6. Decrypting a Message

gpg encrypted_message_file

You will be prompted for the filename to use for the output of the decryption process.

7. Encrypting with a Symmetric Key

gpg --symmetric --armor message_file

8. Signing and Encrypting a Message

gpg --sign --encrypt --armor --recipient message_file

9. Creating a Detached Signature

gpg --detach-sign --armor message_file # Sender
gpg --verify message_file.asc message_file # Recipient

10. Signing Another's Public Key

Alice is going to sign Bob's key.

# First, user A must do:
gpg --sign-key user_B
gpg --export --armor user_B > B.key

# Then, user_b must do:
gpg --import B.key
Read more
0

Execute more than one commands

Executing the second command only if the first is successful

To do this you would type: command1 && command2

command2 will be executed if command1 successfully completes (if command1 fails command2 won't be run). This is called a logical AND.

Executing the second command only if the first fails

To do this you would type: command1 || command2

command2 will be executed if command1 does not successfully completes (if command1 is successful command2 won't be run). This is called a logical OR.

Executing commands sequentially

To execute command sequentially regardless of the success/failure of the previous you simply type: command1; command2

command2 will execute once command1 has completed.
Read more
0

Linux Runlevel Descriptions

Runlevel

Runlevel Description

Runlevel 0

The halt runlevel - this is the runlevel at which the system shuts down. For obvious reasons it is unlikely you would want this as your default runlevel.

Runlevel 1

Single runlevel. This causes the system to start up in a single user mode under which only the root user can log in. In this mode the system does not start any networking or X windowing, X or multi-user services. This run level is ideal for system admins to perform system maintenance or repair activities.

Runlevel 2

Boots the system into a multi-user mode with text based console login capability. This runlevel does not, however, start the network.

Runlevel 3

Similar to runlevel 2 except that networking services are started. This is the most common runlevel for server based systems that do not require any kind of graphical desktop environment.

Runlevel 4

Undefined runlevel. This runlevel can be configured to provide a custom boot state.

Runlevel 5

Boots the system into a networked, multi-user state with X Window System capability. By default the graphical desktop environment will start at the end of the boot process. This is the most common run level for desktops or workstation use.

Runlevel 6

Reboots the system. Another runlevel that you are unlikely to want as your default.

Read more
0

Working with Linux Services

There are number of ways to control what services get started using both command line and graphical tools without having to going into the depths of your Linux system.

The command line tool chkconfig (usually located in /sbin) can be used to list and configure which services get started at boot time. To list all service settings run the following command:

/sbin/chkconfig --list

This will display a long list of services showing whether or not they are started up at various runlevels. You may want to narrow the search down using Linux grep command. For example to list the entry for the HTTP daemon you would do the following:

/sbin/chkconfig --list | grep httpd

which should result in something like:

httpd 0:off 1:off 2:off 3:on 4:off 5:off 6:off

Alternatively you may just be interested to know what gets started for runlevel 3:

/sbin/chkconfig --list | grep '3:on'

chkconfig can also be used to change the settings. If we wanted the HTTP service to start up when we at runlevel 5 we would issue the following command:

/sbin/chkconfig --level 5 httpd on

A number of graphical tools are also available for administering services. On RedHat you can run the following command:

redhat-config-services

The equivalent command on Fedora Core is:

system-config-services

The above graphical tools allow you to view which services will start for each runlevel, add or remove services for each runlevel and also manually start or stop services.
Read more
0

Comparing Three Files by using diff3

The diff3 command compares three files and outputs descriptions of their differences. Its arguments are as follows:

diff3 options... mine older yours

The files to compare are mine, older, and yours. At most one of these three file names may be -, which tells diff3 to read the standard input for that file.

An exit status of 0 means diff3 was successful, 1 means some conflicts were found, and 2 means trouble.

read the man pages for detail options
Read more
Related Posts with Thumbnails