What *nix commands do you want to know more about?

Page 4 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

silverpig

Lifer
Jul 29, 2001
27,709
11
81
Originally posted by: jamesave
what is the command to list out the hardware on a SUN server? trying to figure out how much memory, what is the processors, etc.

cat /proc/cpuinfo
cat /proc/meminfo

I don't know if that will work on the sun server, but it works on my linux boxes... *shrug*
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: silverpig
Originally posted by: jamesave
what is the command to list out the hardware on a SUN server? trying to figure out how much memory, what is the processors, etc.

cat /proc/cpuinfo
cat /proc/meminfo

I don't know if that will work on the sun server, but it works on my linux boxes... *shrug*

I'll check a Sun system when I get to work, but I doubt it has those.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
I have access to what seems to be a SunOS 5.8 machine through school. No idea what that is in Solaris numbers. /proc is just full of folders with pid-looking numbers and I can't make head or tails of their contents But, /proc doesn't seem to have any hardware info.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: kamper
I have access to what seems to be a SunOS 5.8 machine through school. No idea what that is in Solaris numbers. /proc is just full of folders with pid-looking numbers and I can't make head or tails of their contents But, /proc doesn't seem to have any hardware info.

SunOS 5.8 = Solaris 8.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
I added a bunch of stuff to the last post (and then forgot to clean it up a bit :|):

Arguments passed to a script:
Often times a script is written that requires user input. There are generally two ways to accomplish this: 1. prompt the user to input the data, and 2. the user can pass them to the script on the command line itself.

When input is passed to a script on the commandline it's considered an argument, and given a variable. Each argument gets a variable consisting of a number. The number is its place on the command line, the script itself being argument 0. The first item after the script name will be accessible in the variable $1, the second $2, etc.

The total number of arguments on the command line will be accessible in the $# variable. This does not count the program ($0).


Exit status:
When a process completes it offers up an exit status. The exit status is either a 0 for pass or any other number for a failure. Using an exit status of "1" for failures is common.

To determine the exit status for a program, run the program. Afterwards use the command echo $?. The variable $? is the exit status for the last command run, and echoing it to the screen displays it.

While scripting, the exit status can be used to inform a user of a problem. Issuing exit 1 when an error occurs can be useful in troubleshooting.

if statements:
The if statement evaluates a statement and determines action based on parameters set in the statement. The if statement can determine whether a file exists, if it is executable, if it is a block or character device, if it is a directory, etc. if can also be used to compare two strings or numbers. It can determine if one number is greater than another, less than another, equal to another, etc. It can compare strings to determine if they are equal. The opposites can also be determined, ie. if can determine if a file is NOT a symbolic link.

Expressions in if statements may also need to be protected. If a variable is used, and it is not set and populated, it will return the string "". This can be problematic, and many scripters don't want to deal with it. A capital X may be used to help solve the problem, by ensuring each part of the expression will be populated. See the last example for an example of this.

The syntax for if statements is often like this:
if [ expression ] ; then
do stuff if the exrpession is true
else
do other stuff if the expression is false
fi


The else is optional, so a simpler if statement may look like:
if [ expression ] ; then
do stuff if the expression is true
fi


A quick example, combining the exit status information above and the if information:

if [ "$?" -ne "0" ] ; then
echo "Program failed."
exit 1
fi


Broken down:
if [ "$?" -ne "0" ] : If the variable "$?" does NOT equal "0"
echo "Program failed." : echo to the screen the string "Program Failed." so the user knows there is a problem
exit 1 : Set the exit status to 1 because there was an error
fi : Close the if statement

Another example:

if [ -e "/home/ddp" ] ; then
if [ -d "/home/ddp" ] ; then
cd /home/ddp
else
mv /home/ddp /home/ddp.not_a_directory
mkdir /home/ddp
cd /home/ddp
fi
else
mkdir /home/ddp
fi


The first if statement determines whether the file "/home/ddp" exists. If it does exist the second if statement determines whether that file is a directory. If it is a directory, change directory to that location. If not, move the file to another location, create the directory and move to the directory. The first if statement also has an else statement. If the file doesn't exist, the else statement creates the directory.

Last example:
if [ X"${#}" == "X2" ] ; then
prog=${0}
date=${1}
location=${2}
else
echo "Usage:"
echo "script.sh DATE LOCATION"
exit 1
fi


This example determines whether two arguments were passed on the command line. If they were it assigns those arguments to other variables. If not, it echoes a basic usage message and exits with an error.
 

Soggys1stBrat

Member
Jan 1, 2005
68
0
0
Originally posted by: silverpig
Originally posted by: n0cmonkey
Originally posted by: kamper
Originally posted by: Soggys1stBrat
Ok I'm a total newbie in the *nix area. so when I see instructions like this

1. unpack tarball
2. cd lin-seti-<version>
3. ./configure
4. make
5. make install
6. cd
7. adjust .lin-setirc to suit your needs
8. cd lin-seti
9. Start up your internet connection
10. ./lin-seti -t (this downloads the first work unit)
11. follow the instructions of the seti client and download your first work unit
12. ./lin-seti -C 10 (this brings the cache size to 10 units)
13. ./lin-seti -t (this downloads the remaining 9 units)


I'm totally stumped at the unpack tarball. Am I supposed to type these in as commands? And if so where do I type them? If not then how do I do this stuff?
I bolded the parts you should take literally (type them in at the prompt). screw3d provided the instructions for #1

And since when is there an open source seti client? :Q

I think the BOINC client is open.

It's not open source. I use lin-seti myself. It's just a cache manager like seti-driver. The BOINC client is open source, but the program that runs the science is still proprietary (don't want people messing with the science).


So, this isn't the actual command line client then?
 

silverpig

Lifer
Jul 29, 2001
27,709
11
81
Originally posted by: Soggys1stBrat
So, this isn't the actual command line client then?

Lin-seti isn't no, but it runs the command line client. You run lin-seti and set a cache size. It will then download that many work units and pass each one to the cli version of seti you have installed.
 

LeonarD26

Senior member
Feb 12, 2004
826
1
71
Not sure if this is the correct place for this, but does anyone have experience using procmail? Looking for some guidance.

Thanks!
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: LeonarD26
Not sure if this is the correct place for this, but does anyone have experience using procmail? Looking for some guidance.

Thanks!

It's not really a standard unix command. Might as well post a thread in Software forum with a question.
 

eastvillager

Senior member
Mar 27, 2003
519
0
0
Originally posted by: jamesave
what is the command to list out the hardware on a SUN server? trying to figure out how much memory, what is the processors, etc.



prtdiag is the most common to use for this. it'll work in just about any version of Solaris, not sure if it was in SunOS, been a long time since I touched 4.silly.

You can also get stuff from prtconf and cfgadm, depending on your version.

some quick stuff that is handy:

find

find . -name "foo*" -print

will do a recursive search starting at . and list anything that starts with foo. you can do lots of other things besides -print, too, like -exec, etc.

a very quick find on solaris, assuming you're looking for a file that was added as part of the OS, a patch, or a pkg is just:

grep "filename" /var/sadm/install/contents Anyways, that file lists EVERY file, directory, link, pipe, etc., installed by the OS, patches, and/or pkgs.

I use awk a lot too, but nothing too complex. stuff like

cat /etc/hosts | awk ' { print $2 } '

which will print out the first hostname listed on each line. I usually use it more for devices, especially when working with veritas diskgroups/volumes/dgs/disks and regular old luns.

luxadm probe will list most of your fiber-attached devices, assuming they're not LUN-masked, or zoned. Lots of junk to do with luxadm, especially if you do fiber-attached array work direct or SAN-attached.

hmm, what else do I use all the time? silly stuff like

pwd
who
w
last
pkill sendmail (hehehehehe)
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: bersl2
Originally posted by: n0cmonkey
Originally posted by: hooflung
wine

That's pretty Linux specific.

Actually, I believe that WINE works under x86 Solaris. And let's not forget the fork Darwine that will run on Intel Macs.

Ok, so you're saying it isn't Linux specific. How about "no because it's too non-standard?"
 

bersl2

Golden Member
Aug 2, 2004
1,617
0
0
Originally posted by: n0cmonkey
Originally posted by: bersl2
Originally posted by: n0cmonkey
Originally posted by: hooflung
wine

That's pretty Linux specific.

Actually, I believe that WINE works under x86 Solaris. And let's not forget the fork Darwine that will run on Intel Macs.

Ok, so you're saying it isn't Linux specific. How about "no because it's too non-standard?"

That would work.
[/pedantic]
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: bersl2
That would work.
[/pedantic]

Feel free to write something up about them. I just know I'm not going to do it. Not only do I not need WINE, I can't use it.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
How about a brief explanation of the common uses of screen? I know I'm just being lazy here because I could just find a tutorial or even read the man page, but you're offering...

Are there any major differences between the gnu version and whatever comes with a BSD (or even among the BSDs)? I think most documentation out there, besides man pages would probalby be gnu specific.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: kamper
How about a brief explanation of the common uses of screen? I know I'm just being lazy here because I could just find a tutorial or even read the man page, but you're offering...

Are there any major differences between the gnu version and whatever comes with a BSD (or even among the BSDs)? I think most documentation out there, besides man pages would probalby be gnu specific.

screen is screen. What's to know?
 

Sunner

Elite Member
Oct 9, 1999
11,641
0
76
Might as well throw in xargs since IMO it's one of those commands that really make some things way easier.
To quote from the manpage:
xargs reads items from the standard input, delimited by blanks (which can be protected with double or single
quotes or a backslash) or newlines, and executes the command (default is /bin/echo) one or more times with any initial-arguments followed by items read from standard
input.
You can do some nifty stuff with it, a simple example would be if you wanna remove a bunch of files named .tmp, you could do something like:
find . -name *.tmp|xargs rm, find will send the filenames to stdout, xargs will execute rm with the filenames as arguments.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |