Tuesday, September 13, 2011

Unix cd commands?

How do I change from one directory to a second directory without having to go to the root and then typing to filepath for the second directory?Unix cd commands?
Hi, I don't think its important to go to root unless u perform a task with administrator privileges.



In konsole:

cd /home : this will take u to ur home directory



now u want to get out of it only one step back, so u type



cd ..



If u want to reach the default location from cd /home they type



cd



If u want to see the list and names of all folders and directories in the directory u have ';cd'; to then type:



dir



If u want full time root access without using the sudo command then type:



su

then your password



in some systems u need to type



sudo su

then your password



Be careful though running as root is a security risk so make sure u r not online at least so u don't expose yourself.



Good Luck and take care!Unix cd commands?
instead of dir try ls or ls-h to see hidden files, if you find it hard to do try downloading a copy of midnight commander, theres a version for most distros about.



oops nearly forgot, if you do download it and install it all you do then is type mc at the prompt
I don't fully understand what you are trying to convey.



In all the years that I have been using Linux (Unix variant), I have never had to go to the / in order to change to other directory.



from any directory, typing 'cd' gets you to your $HOME. you can supply it an argument which has to be an existing path.



An absolute path begins with a '/' and relative path does not being with a '/'.
cd /full_path_to_file



you can run this command from anywhere... for instance if I am in the /etc directory and want to switch to the /var directory I can type



cd /var



or you can use relative paths ';..'; is a shortcut for the parent directory (back one directory) so to go from /var/adm to /var/spool I can use



cd ../spool



also I can create a variable for instance you need to get to the /opt/sfw/bin directory every few minutes you can create a variable $osb by:



osb=/opt/sfw/bin

cd $osb



in some shells you can cd to the last directory you were in by using a ';-';. If you are in /etc and was just in /var/spool you can go back to /var/spool by



cd -

No comments:

Post a Comment