When to work as root & When to Work as a System User
来源:互联网 发布:川农在线网络教育平台 编辑:程序博客网 时间:2024/06/05 06:21
When you should work as root
You have now installed Linux and the first thing you did was login as 'root'. Then you provided a password so that you and ONLY you could login to the system as 'root'.When you decide to work as root, you had better go into a phone booth first and change into a blue suit with a big 'S' on the front because 'root' is known as the 'superuser' (you can skip the red tights if you want).
That's really not meant to be just a witty诙谐的;幽默的 reference to the Man of Steel. Actually, it is much more glamorous to be 'Superman' but root is actually more like the'janitor' 看门人 of the Linux system. Root has the keys to everything. He can shut off the lights, shut off the heat, lock you out of the building; he has to clean up the system and in the end make sure everything runs. And the most important thing about being a janitor - he sees everything.
'root' is not for routine work
As I mentioned, Linux makes your computer a true multi-user system, which means that besides root, you can and should work as another person. I say 'should' because doing routine work as 'root' could behazardous冒险的 to your health. When I first started using Linux myself, information was not all that readily available and I still had that 'one computer- one user' concept in my brain. It was after I had trashed all of the files and programs that make Linux run that I realized that working regularly as root wasn't a good idea.
Working as another user
Well, then how do you do your day to day work with Linux? That's easy. You do it by working as a user other than root. You may pick the name you like. Try your name. If your name is "Bob" then you could create a user account for 'bob'. By the way, if Prince Charles is reading this, Charles Philip Arthur George is a bit too long and has spaces, which Linux doesn't like - he should try 'charlie'. One thing I find EXTREMELY helpful is that with Linux, I can work as different people. It should not be inferred here that I have split-personality disorder. I am just a guy with a couple of different jobs. This way I can organize my work a lot better and backups are easier this way too.
Adding a new user
Well, Bob, now it's time to create your account. If your name is Hrothgar, use 'Hrothgar' or 'Hrothie' instead of 'bob' for the remainder of the lesson.
Now 'root' has to do this stuff. Yes, I know I just warned you about working as root, but this is where you have to exert your authority. Most major distributions have tools to do this. SuSE, for example, has a nice tool called YAST which lets you add users painlessly. You just fill in the correct information. Consult your Linux version for information on their tools. There is also the get-your-hands-dirty way of doing this. Actually you won't get your hands dirty unless you're eatingbarbecued ribs肋骨 at the same time.
Using 'useradd' and 'passwd'
To add a new user, you can also use the command 'useradd'. Kind of a logical name, isn't it?
Try this:
Code:
useradd bob
You probably won't see any fireworks go off. You might not see anything. That doesn't matter. Linux has been told that there's a new user and his name's 'bob'.
Now you should give yourself a password.
Do this:
Code:
passwd bob
Linux will ask you for your password. Follow the same advice I gave previously about passwords. Also, don't use your 'root' password. Like 'one man, one vote' it's 'one user - one password'. You will be asked to repeat it.
What's in your user directory
When you create a new user, there is a directory created for that user in /home. To see what's in this new directory, you have to do the following.
Go to the /home directory. - typing:
Code:
cd /home
you can make sure you're in the /home directory by typing:
pwd
You'll see this: /home.
Now you need to type:
Code:
cd bob
You can type:
Code:
ls -a
to see what's in the directory. We'll go into more detail with the ls command later. With the -a option, you'll see some files that begin with a '.' (period/dot). Those would normally be hidden from you if you didn't use the -a.
Now you can go to work as 'bob', 'pcharles' or whoever you happen to be.
You have now installed Linux and the first thing you did was login as 'root'. Then you provided a password so that you and ONLY you could login to the system as 'root'.When you decide to work as root, you had better go into a phone booth first and change into a blue suit with a big 'S' on the front because 'root' is known as the 'superuser' (you can skip the red tights if you want).
That's really not meant to be just a witty诙谐的;幽默的 reference to the Man of Steel. Actually, it is much more glamorous to be 'Superman' but root is actually more like the'janitor' 看门人 of the Linux system. Root has the keys to everything. He can shut off the lights, shut off the heat, lock you out of the building; he has to clean up the system and in the end make sure everything runs. And the most important thing about being a janitor - he sees everything.
'root' is not for routine work
As I mentioned, Linux makes your computer a true multi-user system, which means that besides root, you can and should work as another person. I say 'should' because doing routine work as 'root' could behazardous冒险的 to your health. When I first started using Linux myself, information was not all that readily available and I still had that 'one computer- one user' concept in my brain. It was after I had trashed all of the files and programs that make Linux run that I realized that working regularly as root wasn't a good idea.
Working as another user
Well, then how do you do your day to day work with Linux? That's easy. You do it by working as a user other than root. You may pick the name you like. Try your name. If your name is "Bob" then you could create a user account for 'bob'. By the way, if Prince Charles is reading this, Charles Philip Arthur George is a bit too long and has spaces, which Linux doesn't like - he should try 'charlie'. One thing I find EXTREMELY helpful is that with Linux, I can work as different people. It should not be inferred here that I have split-personality disorder. I am just a guy with a couple of different jobs. This way I can organize my work a lot better and backups are easier this way too.
Adding a new user
Well, Bob, now it's time to create your account. If your name is Hrothgar, use 'Hrothgar' or 'Hrothie' instead of 'bob' for the remainder of the lesson.
Now 'root' has to do this stuff. Yes, I know I just warned you about working as root, but this is where you have to exert your authority. Most major distributions have tools to do this. SuSE, for example, has a nice tool called YAST which lets you add users painlessly. You just fill in the correct information. Consult your Linux version for information on their tools. There is also the get-your-hands-dirty way of doing this. Actually you won't get your hands dirty unless you're eatingbarbecued ribs肋骨 at the same time.
Using 'useradd' and 'passwd'
To add a new user, you can also use the command 'useradd'. Kind of a logical name, isn't it?
Try this:
Code:
useradd bob
You probably won't see any fireworks go off. You might not see anything. That doesn't matter. Linux has been told that there's a new user and his name's 'bob'.
Now you should give yourself a password.
Do this:
Code:
passwd bob
Linux will ask you for your password. Follow the same advice I gave previously about passwords. Also, don't use your 'root' password. Like 'one man, one vote' it's 'one user - one password'. You will be asked to repeat it.
What's in your user directory
When you create a new user, there is a directory created for that user in /home. To see what's in this new directory, you have to do the following.
Go to the /home directory. - typing:
Code:
cd /home
you can make sure you're in the /home directory by typing:
pwd
You'll see this: /home.
Now you need to type:
Code:
cd bob
You can type:
Code:
ls -a
to see what's in the directory. We'll go into more detail with the ls command later. With the -a option, you'll see some files that begin with a '.' (period/dot). Those would normally be hidden from you if you didn't use the -a.
Now you can go to work as 'bob', 'pcharles' or whoever you happen to be.
阅读全文
0 0
- When to work as root & When to Work as a System User
- [知其然不知其所以然-30] How to work around when system can not be woken up
- Swift Optionals: When to use if let, when ? and !, when as? and as
- Swift Optionals: When to use if let, when ? and !, when as? and as
- The user specified as a definer ('root'@'') does not exist when
- How to Successfully Pretend to Work Hard as Software Developer?
- IDLE_TIME DOES NOT WORK TO SPECIFY WHEN A SESSION IS AUTOMATICALLY SNIPPED
- On a new installed FreeBSD server, when you try to SSH to the server as root, you will end up in the
- What components are not suitable to work as component interfaces
- how to fix the assembly problem when project A call project B as reference
- Got error: 1449: The user specified as a definer ('root'@'%') does not exist when using LOCK TAB
- mysqldump报错'The user specified as a definer ('root'@'%') does not exist when using LOCK TABLES'
- Gearman - A system to farm out work to other machines
- When does IsIconic() work?
- IIS runs out of work items and causes RPC failures when connecting to a remote UNC path
- What to Do When You Have to Work with Someone You Don't Like
- CentOS安装Chrome及Please start Google Chrome as a normal user. To run as root, you must specify an ...
- emacs as work environment
- 关于多线程的一些基础整理
- 如何把table封装成一个字符串
- 关于线程的同步
- linux下使用yum安装mysql
- CentOS7安装Nginx1.10.1详细图解教程
- When to work as root & When to Work as a System User
- java 同步/异步IO和阻塞/非阻塞IO 关系和概念解析
- 利用GPU实现翻页效果
- hdu 6148 Valley Numer (数位dp)
- 原码、反码、补码、和位非的关系
- Flask的url_for函数
- QT 过滤文件夹下指定文件
- 线程与进程区别原理分析java编程思想
- MyEclipse 快捷键