20061018

From Wsms

Jump to: navigation, search

previous next


Go To:Linux Class Notes

Wednesday Oct 18 2006

Contents

Sending files with ssh

When you send a configuration file, you can deeply modify the system. There must exist procedures to do the best to ensure the safety of the system.
Now, we are going to edit the file /etc/ssh/ssd_config
  1. Make a copy of the line related to permit root login.
  2. Don't allow root login
  3. close and save the file
  4. type "service sshd restart" in the command line
Now, nobody can login to the server as a root user
They have to connect as another user, and then use the su to get to the root user.

some useful tools

VI editor

Joe gives us a copy of a reference card to vi.
Outside this facility, we have to use the rop.ncc.sdcc.net domain name to get connected to our server.
We begin to work with vi in command and editing mode.
Here is a question: Why do we have to learn and get skills in vi or any other editor under linux?
Here is an interesting 'vi' manual site: http://www.eng.hawaii.edu/Tutor/vi.html
There are dozens of editors in Unix. vi is one of the most popular

GREP command

To search through files from the command line.
Example:
Being in the /etc/ssh folder, type
grep Root *
You will obtain the following output:
sshd_config:PermitRootLogin no sshd_config:# "PermitRootLogin without-password". If you just want the PAM....
It is used to filter data in a text source.

It can also be used to search for a string that maybe contain one of many files on a file system.
For further information, you can look to: http://pegasus.rutgers.edu/~elflord/unix/grep.html

ps command

To view the current processes.

printenv

Used to see the environmet variables. It will show all the environmental variables asociated with the current user.
To see the content of one environmental variable, it is possible to use the command echo like this:
echo $PATH
echo $HISTZISE
There are 4 files asociated with the environmental variables:
/etc/profile
/etc/bashrc
This two apply to all users if they exists. Anything that is intere will be common for all users.
~/.bash_profile
~/.bashrc
There might not be anything in those files. Those files are in each of anyone home directory. Those files exist to make the users be able to "localy" modify things that are set in the other two files that are common for all users in the /etc directory.

One of these files is processed anytime you enter interactively and the other is proccessed anytime you enter using a shell.
When you enter via another shell (like using su or running a script), only one of those files load and set the environmental varialbles.

export

Once you change an enviromental variable's value, you must export it, so you affect the value the system has for you.
Example:
  1. open the .bash_profile with vi
  2. add this two lines:
HISTSIZE=2000
export HISTSIZE

With that change made, you can open a new terminal window and see that the value has changed by typing echo $HISTSIZE, that will be set to 2000 for that user.
This command is built in in bash.

Questions

1. How do I fix something I screwed up using the .bash_profile file? (copy command)

Answer: There is a folder called /etc/skel, wich was copied when you were aded as a user. When you screw one of those files up, you can go to that directory and copy that file again in the way it was made when your account was created adding you as a user.
The solution is the copy command

cp /etc/skel/.bash_profile .


Personal tools