Commands you might have missed

Posted by Steve on Tue 15 Jul 2008 at 11:25

There are a lot of articles upon this site, and it appears that many of the most popular are those that are written with the complete beginner in mind. After realizing this I've got a decided to introduce a miniseries covering a few easily-overlooked tools and commands over the next week.

There are many scripts, tools, and commands available upon the average Debian GNU/Linux system. To the extent that I'm often amused that I've made a typo and accidentally invoked a valid command!

(xlogo was a command I only discovered by accident, for example. As was sl.)

For the next seven days I'll be introducing some of the commands which I use frequently, and may well be new to you.

If you have any suggested tools, or useful Debian packages that you'd like to recommend then please feel free to create your own article, or mention them in a comment.

Share/Save/Bookmark


Posted by Anonymous (62.64.xx.xx) on Tue 15 Jul 2008 at 12:59
$ lsb-release -a
wery useful, epecialy when newbee asking you for help )

[ Parent | Reply to this comment ]

Posted by Anonymous (89.16.xx.xx) on Tue 15 Jul 2008 at 15:41
The right command is "lsb_release -a" (note the underscore instead of the hypen).

Cheers

[ Parent | Reply to this comment ]

Posted by Anonymous (89.16.xx.xx) on Tue 15 Jul 2008 at 22:30
commands I found which are not often talked about:

useful for scripting:
join
paste
rev, tac

useful for administration:
newgrp, sg
pwdx
namei

programming (maybe):
nl

[ Parent | Reply to this comment ]

Posted by Anonymous (84.114.xx.xx) on Wed 16 Jul 2008 at 19:40
Very usefull when dealing with interactive tools: yes
The "yes" utility seems to be around in Unix systems forever.

-MB-

[ Parent | Reply to this comment ]

Posted by unixsurfer (212.136.xx.xx) on Thu 17 Jul 2008 at 10:31
[ Send Message ]
seq(1) is quite handy in loops

sustdevl1][~]
for n in `seq 1 3`; do uptime;done
10:53:54 up 492 days, 19:16, 2 users, load average: 0.00, 0.00, 0.00
10:53:54 up 492 days, 19:16, 2 users, load average: 0.00, 0.00, 0.00
10:53:54 up 492 days, 19:16, 2 users, load average: 0.00, 0.00, 0.00

[ Parent | Reply to this comment ]

Posted by Anonymous (86.10.xx.xx) on Thu 17 Jul 2008 at 22:41
for n in `seq 1 3`; do uptime; done << 35 characters

uptime
uptime
uptime << 18 characters

The latter option is even less if you consider pressing <UP> and <ENTER> to be pretty easy, as most people probably do ;)

uptime
<UP> <ENTER>
<UP> <ENTER> << 10 characters

Moral of the story: sometimes you *really* don't need to use a for loop ;) Rather like pointless uses of cat, a la -- `cat file | grep <pattern>`.

[ Parent | Reply to this comment ]

Posted by Anonymous (205.142.xx.xx) on Mon 21 Jul 2008 at 18:19
I think you missed the point. He was just illustrating how the loop works, and I certainly hope no one wants to run uptime 3 times in a row with no command changes. Here is something that might be a little clearer as to how powerful that loop structure is:

for i in `seq 1 4`; scp file server0$i.domain.com:/home/user/; done

That will scp a file to servers01-04 without having to go back and edit the command 4 times.

[ Parent | Reply to this comment ]

Posted by Anonymous (193.178.xx.xx) on Fri 18 Jul 2008 at 09:49
To search a string inside all the files (except .log files) in the current directory and its sub-directories

find . -type f -not -name "*.log" -exec grep "text_to_search" '{}'\; -print

[ Parent | Reply to this comment ]

Posted by yarikoptic (69.125.xx.xx) on Sat 26 Jul 2008 at 04:48
[ Send Message ]
then another 'missed command' might be 'xargs'... with it you don't need to escape or wrap things thus smth like
find . -type f ! -name "*.log" | xargs grep "text_to_search"
would be more native and more flexible imho (xargs has quite few params to satisfy needed party)

[ Parent | Reply to this comment ]

Posted by Anonymous (66.33.xx.xx) on Fri 15 Aug 2008 at 19:39
include the -H flag with the grep and it will provide the matching filname.

[ Parent | Reply to this comment ]

Posted by Anonymous (81.57.xx.xx) on Sun 24 Aug 2008 at 10:17
Even better, if you want to handle filenames with spaces or newlines (or quotes or backlslashs) correctly, use the null-seperated-items find (-print0) and xargs (-0) options. That's the "robust find | xargs" paradigm. Like this :
find . -type f ! -name "*.log" -print0 | xargs -0 grep "text_to_search"

Also little known is the ability of grep to automaticaly color matched patterns when supported by output (ie. grep will disable this automaticaly if piped on an other command, redirected to a file, etc). And as said above, "-H" is useful for such use case.
So we have now, with "robust paradigm" and more eye-candy :
find . -type f ! -name "*.log" -print0 | xargs -0 grep -H --color=tty "text_to_search"

[ Parent | Reply to this comment ]

Posted by yarikoptic (69.125.xx.xx) on Sun 24 Aug 2008 at 17:09
[ Send Message ]
if we came to coloring of grep output-- I just have
GREP_OPTIONS="--color=auto"
in my environment ;-)

[ Parent | Reply to this comment ]

Posted by Anonymous (79.23.xx.xx) on Sun 3 Aug 2008 at 18:35
I find these tools quite userfull:
- jnettop
- vidir
- discus
- screen

And for having lessons and lectures:
- sm
- figlet

[ Parent | Reply to this comment ]

User Login

Username:

Password:

[ Advanced Login ]

Register Account

Quick Site Search