Tuesday, 20 August 2019

How to get back to previous directory

Very often I need to "jump" back to previous directory. There is a form of cd command to allow this: 
#cd -

[root@rifle ~]# pwd
/root
[root@rifle ~]# cd /etc/postfix/
[root@rifle postfix]# pwd
/etc/postfix
[root@rifle postfix]# cd -
/root

Tuesday, 13 August 2019

Search help for the linux commands

Search help for the linux commands

Sometimes you need to search what certain linux command does or what arguments the command needs.

There are several ways:

1. Ask coomand itself for help

Usually by adding --h or --help to command.
[root@rifle ~]# ls --help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

Mandatory arguments to long options are mandatory for short options too.
  -a, --all                  do not ignore entries starting with .
.
.
.

Some commands needs -help parameter.
[root@rifle ~]# zip -h
Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
Zip 3.0 (July 5th 2008). Usage:
zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]
.
.
.

  -A, --show-all           equivalent to -vET
  -b, --number-nonblank    number nonempty output lines, overrides -n

2.Using man command

[root@rifle ~]# man ls

3.Using man command --k parameter

[root@rifle ~]# man -k sysctl
_sysctl (2)          - read/write system parameters
sysctl (2)           - read/write system parameters
sysctl (8)           - configure kernel parameters at runtime
sysctl.conf (5)      - sysctl preload/configuration file
sysctl.d (5)         - Configure kernel parameters at boot
systemd-sysctl (8)   - Configure kernel parameters at boot
systemd-sysctl.service (8) - Configure kernel parameters at boot

4. Using apropos or whatis commands

[root@rifle ~]# whatis ls
ls (1)               - list directory contents
ls (1p)              - list directory contents

5.Search the web






cat and tac commands

cat and tac commands

cat -  cat - concatenate files and print on the standard output
tac - concatenate and print files in reverse

[root@rifle ~]# cat one.txt
There are just some text lines.
And again...
And again...
[root@rifle ~]# tac one.txt
And again...
And again...
There are just some text lines.