Structure your individual Linux cheat sheets

Uncategorized

Linux guy pages can be overwhelming to people who are simply finding out how to deal with the command line, but here we’ll look at a way to quickly prepare a cheat sheet for a series of commands. These cheat sheets will inform new Linux users enough to begin and understand what man page to check out when they would like to know more.To get going, we’ll take a look at series of commands that any Linux beginner would need to discover:

alias cmp export less tail whereis apropos comm grep more tar who feline dd head passwd top whoami chmod df eliminate pwd unzip zip chown diff killall sort whatis

Next, we utilize a series of commands that will provide brief descriptions of these commands. These are assistance -d, whatis, and a guy command that picks just the command description from the male pages.help -d The assistance -d

command will offer a one-line description for a few of the celebration built-ins.

$ help -d pwd – Print the name of the current working directory site.

The male -f and whatis commands

The male -f command and the whatis command produce the exact same outcomes. Here are some examples:

$ whatis cd (1) – celebration built-in commands, see celebration( 1) $ guy -f cd (1) – celebration integrated commands, see bash( 1 )

Getting the 4th line from the man page

The fourth line of each male page contains a brief description of the command. The script listed below gets this by taking the top 3 lines (using the head command) and then just displaying the last of them (utilizing the tail command).

Getting the description from the male page

To obtain just the brief description from a command’s guy page, you can use a command like this:

$ guy date|head -4|tail -1 date – print or set the system date and time

Using a script

To use each of the techniques explained, you can run a script like the one shown below that runs through the series of commands you provide (listed in a file) and develops a cheat sheet utilizing each of the commands described. This script calls the resultant files help1, help2, and help3. Keep in mind that it silences any error message (e.g., when it can’t find a description for a specific command) and otherwise adds a line to one of the 3 files.

#!/ bin/bash # empty CheatSheet files if they exist > help1; > help2; > help3 # get name of command list echo -n “lisf of commands >” read list # sort command list sort $list > $list$$ # run through command list and collect descriptions for cmd in ‘feline $list$$ do help -d $cmd 2 >/ dev/null >> help1 whatis $cmd 2 >/ dev/null|grep ^$cmd 2 >/ dev/null >> help2 man $cmd|head -4|tail -1 2 >/ dev/null >> help3 done # remove sorted commands file rm $list$$

Outcomes

The outcomes below reveal the leading 10 lines from each of the files.

$ head -10 help1 help2 help3 ==> help1 <== alias - Define or display aliases. command - Execute a simple command or display information about commands. export - Set export attribute for shell variables. kill - Send a signal to a job. pwd - Print the name of the current working directory. ==> help2

Leave a Reply

Your email address will not be published. Required fields are marked *