LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Blogs > error_401
User Name
Password

Notices

Rate this Entry

Tutorial about information gathering and the most important commands

Posted 01-11-2013 at 04:32 AM by error_401
Updated 02-08-2013 at 01:36 AM by error_401

Have you been in this situation?

You have finally installed your first linux and have a problem. Now everybody wants to know what you have installed in order to answer your question. But how to get there?

Little tutorial about gathering information on a linux system.

First know the difference between a normal user and "root". Root is the administrator. You are not normally logging on as root but if it is your own computer you may do so at your own risk. Root can do everything on a computer running linux, so commands such as
Code:
rm -r *
are a very bad idea! (Would do: rm=remove -r=recursive *=placeholder for "all")

You can determine if logged in as a normal user or root by looking at the prompt in the console on normal linux installs.

The normal user shows the $ sign at the end of the prompt while the root shows #. The names before the @ are normally indicative as well but may not be so obvious as "root".

Code:
user@computer1:~$
Code:
root@computer1:~#
Some systems and installations support sudo which is an acronmy for "super user do" which temporarily grants a user root rights without the need for a separate login. Open a terminal with the user you work with and type su or sudo depending on distro, followed by the respective password when asked.

Then we need to make sure you know what a console is. A console can either be a window such as the "cmd" window in MS Windows or the full screen when selecting a tty (terminal) using e.g. Ctrl+Alt+F1 to F6. A console is that scary bit of black screen with a blinking cursor. No mouse. No graphics. No clutter but powerful as h..ll.

Information gathering can be as simple as opening system info e.g. in KDE desktop from the systems menu or a bit more work when using the console.
Getting to grips with information gathering e.g. to address the forum:

HELP COMMAND
use the command followed by --help to see all the parameters possible or to see what I am recommending you to do. Scroll down to the section about the "MORE" command if the output overflows. E.g.
Code:
lspci --help
LINUX VERSION AND DISTRO
Code:
cat /proc/version
INSTALLED DEVICES ON PCI BUS
Code:
lspci
NETWORK ADAPTERS AND BASIC INFO
Code:
ifconfig -a
HARD DRIVES - CAUTION using fdisk with other options than -l is dangerous!
Code:
fdisk -l
USB DEVICES
Code:
lsusb
PROCESSOR INFORMATION
Code:
cat /proc/cpuinfo
HOW TO GET IT OUTPUT INTO A FILE
When working within the graphical environment you may use the mouse to mark and copy the output so you can put it directly e.g. into the forum editor. But when working on a tty this won't work. So we need a workaround.

PIPING OUTPUT SOMEWHERE
All the above commands should also work with piping the output into a text file. This can be done by using > after the command followed by a filename. Normally using the normal user I would create a directory path in my /home/ directory let's say "/home/user/system-information" into which I can output the information of the above commands. We need a bit more of fiddling later on - but let's create the directory first:

CREATING A DIRECTORY
Either using your graphical file manager create the directory or when logged into a console window do:
Code:
cd /
(to get to the root of your user directory) You should have a prompt like this:
Code:
user@computer1:~$
When you see the $ sign this means you are logged as normal user.
Now we create the directory using:
Code:
mkdir system-information
.

LISTING DIRECTORIES
when using
Code:
ls -l
you should find an entry for "system-information".

THE "MORE" COMMAND
If the output is too long you can always use the more command after e.g. ls with a vertical bar separated by spaces. It would be used like this:
Code:
ls -l | more
To continue reading the next page use the space bar, to advance one line use Enter or to quit use Ctrl+c.

Now change the user to root or just try how far you get using the normal user with the above commands. Most should just work fine without the root privileges. Let's output some information to a file:
Code:
cat /proc/cpuinfo > system-information/cpu-info.txt
Which writes the output into a text file named cpu-info.txt in the directory we have created before. When logged in as root whe have an additional step to perform because of privileges. When creating a file with root a normal user cannot access it. So we need to change the file permissions.

CHANGING DIRECTORY AND LISTING CONTENTS
As root go to the directory using the cd command for "change directory".
You can go step by step e.g.
Code:
cd /home
then have a look with
Code:
ls
and then change again to the users directory using
Code:
cd/user
. Going back one step can be done by
Code:
cd ..
Going back to the root by
Code:
cd /
. Together with the
Code:
ls
command with the parameters
Code:
ls -l
or
Code:
ls -al
these are the most important to navigate in the linux filesystem. You can also access a directory directly from anywhere such as:
Code:
cd /home/user/system-information
You need to understand, that when using the normal user your root is already the /home/user/ while the user "root" can go a couple steps higher on the file systems tree.

CHANGING FILE PERMISSION
I found a nice tutorial about chmod here: http://www.tuxfiles.org/linuxhelp/filepermissions.html For completeness we'll simply change all the files we have created in the directory to be read/write/execute for everybody using numeric mode.
Change into the directory "system-information" and list all files with the list structure command described above
Code:
ls -al
in oder to see permissions at the beginning of each line such as: -rw-r--r--. Then change permissions with
Code:
chmod 777 *
Now list the files again using
Code:
ls -al
and have a look at the permissions again which will show something like: -rwxrwxrwx

Now you can use these text files to copy paste the text into the forum editor using e.g. "Kate" in KDE or the OpenOffice Writer.

Have fun with Linux and a look into the LQ forum
http://www.linuxquestions.org/questi...uestion-71791/

http://www.linuxquestions.org/questi...-forum-103564/
Posted in Uncategorized
Views 435 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 06:28 PM.

Main Menu
Advertisement

My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration