Basic Linux command line question


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Basic Linux command line question
# 1  
Old 03-06-2017
Code Basic Linux command line question

SmilieSmilieSmilie
These are list of command i typed on opensuse terminal and evolve lots of doubt around ,that i can't answer.


Code:
COMMAND 1   linux-xavv:/ # cd
COMMAND 2   linux-xavv:~ #

Does above command 1 and command two with red labelled sign make different meaning or same .

1

Code:
linux-xavv:/ # pwd
/

what does that (/) means in above


2

Code:
linux-xavv:/ # cd
linux-xavv:~ # pwd
/root


After clicking cd in command line . my working directory is changed to /root .
what is difference between question 1 and 2 . Am i a root or other user

3

Code:
linux-xavv:~ # su james
james@linux-xavv:/root> pwd
/root

even after entering a user as james. i still found my working directory is /root.
am i in root or in user James account.

4

Code:
james@linux-xavv:/root> cd..
james@linux-xavv:/> pwd
/

5

Code:
james@linux-xavv:/> su
Password: 
linux-xavv:/ # pwd
/

i return to root access and found / ..does that mean i am in root or any thing else
Code:
linux-xavv:/ #


Last edited by Scrutinizer; 03-06-2017 at 01:19 PM.. Reason: code tags; changed "doubt" to "question" in thread title
# 2  
Old 03-06-2017
Hi,

OK, there are various things going here that perhaps need explaining. About the simplest way I can think of tackling your questions is to start with explaining what each of these commands actually does, which might help you understand what you're seeing a bit better.

pwd
This command will print out what's called your current working directory. Your working directory is the directory in the filesystem that you're in at the moment. You change directories with the..

cd
command. cd changes directories, and nothing else. So it's the command you use to change your working directory, and navigate around the filesystem.

su
The switch user command. Nearly always used as a regular user to switch to assume the permissions of the root user. root is the super-user account - that is, the account on a UNIX system that (usually) has full access to all directories and parts of the system, and has permission to run all commands.

Next, I think it would be helpful for you to realise there's a clear distinction between users and directories. Broadly speaking, every user on a UNIX system has one directory on the system reserved for their own use, called their home directory. Typing cd on its own will take you back to this home directory in almost all circumstances. But this home directory needn't have the same name as the user, and can be anything at all. Likewise, any directory on the system can take any name. Every directory on the filesystem will be owned by one particular user and one particular group.

Now, when you use su, the default behaviour will be to leave you in whatever directory you happen to be in at the time, rather than to switch you to the home directory of the user you're wanting to become. If you want it to do that (and more besides), try using the syntax su - instead. This will execute the full login environment of the user you're switching to, and so you will find your current working directory will change to their home directory.

Anyway, hope all this helps you to understand a bit more clearly what's going on here.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

A question about Subversion and commit from the command line

Hey guys, so I want to start using the terminal when I do thinks like update, commit and whatnot. I am use to using kdesvn which is a GUI that helps me with subversion. However, kdesvn does not seem to play well on 18.04 and regardless I am trying to move away from GUI's in general. I want to... (1 Reply)
Discussion started by: Circuits
1 Replies

2. UNIX for Beginners Questions & Answers

Question on bash command line

OS : RHEL / Oracle Linux 6.8 In bash shell, how can I replace a character under the cursor with another character ? In the below example , after I typed the following line, I realized that I meant 7013 and not 2013. So I move the cursor to the left and keep it on top of 2 (of 2013) and I want... (7 Replies)
Discussion started by: kraljic
7 Replies

3. Shell Programming and Scripting

Basic line reading and file merge question

No doubt these questions have been answered many times, but I struggled to find them - sorry. 2 questions: 1. I wish to read in a file one line at a time and do 'stuff' with it, such as: file="tst2" while IFS= read -r line do echo `wget -qO -... (3 Replies)
Discussion started by: Golpette
3 Replies

4. UNIX for Dummies Questions & Answers

Basic IF Command Question

Hi, I have a months worth of data that I need to separate into weekly files. There is a date column with dates in the following format: YYYYMMDD. I'm thinking I can create the weekly files by using a grep command combined with an IF command and specify each day of the specific week I'm... (1 Reply)
Discussion started by: cwl
1 Replies

5. UNIX for Dummies Questions & Answers

Unix command line question

I'm new to Unix and I'm looking for some assistance. We have 20 different accounts we must login to every day. Logging in has become quite the chore and most nights, we have to log out. I'm looking for a way to simply copy and paste the commands into each window to make things easier. I have been... (2 Replies)
Discussion started by: Judo_Bear
2 Replies

6. UNIX for Dummies Questions & Answers

Basic awk question...getting awk to act on $1 of the command itself

I have a script problem that I am not able to solve due my very limited understanding of unix/awk. This is the contents of test.sh awk '{print $1}' From the prompt if I enter: ./test.sh Hello World I would expect to see "Hello" but all I get is a blank line. Only then if I enter "Hello... (2 Replies)
Discussion started by: JasonHamm
2 Replies

7. Linux

Basic Linux Shell Command

I'm working with telnet under windows and Xming. I connect to a network computer and I open Xterm. With Xterm I want to be able to open more than one windows like firefox, nedit etc. Example : When a open firefox on the xterm, I type "firefox", after that, I cannot make an other command until I... (1 Reply)
Discussion started by: Meccos
1 Replies

8. Solaris

shutdown question from command line

solaris 10 logged in as root to command line...want to shut the system down....could not do this....when i chose shutdown the system seemed to squawk at me saying i'd lose whatever i was working on would be lost unless i logged out...after proceeding through this it took me to the gui log in... (6 Replies)
Discussion started by: drisnya
6 Replies
Login or Register to Ask a Question