Most of this information already exists at https://help.ubuntu.com/community/BasicCommands - this page should be merged with that one. Also, note that Ubuntu uses 'sudo' rather than 'su' - there is no need for an intro guide to go into 'su' usage. -- Madpilot 2006-08-10 02:12:24 Yman says: Is this the place for debate over a page? anyhow, I wrote an incomplete guide based on my learning proccess, as the title hints. this isn't dry facts like you find at BasicCommands, but rather a juicier one full of examples to get you started. in my opinion BasicCommands would be great as a reference and should have a link at the bottom of this page. by the way, I find it incredible that you edited a page you think shouln't exist.
su – switch user. general description: you can use this command to perform actions as a different user.
how to use it: type the command, followed by the user name of the user you want to switch to. if you don't specify a user name you would be switching to the root user. example 1: yman@yman-laptop:~$ su zman Password: zman@yman-laptop:/home/yman$
this makes me be the user called “zman”. to switch back to yourself, just type in the “exit” command. it goes like this: yman@yman-laptop:~$ su zman Password: zman@yman-laptop:/home/yman$ exit exit yman@yman-laptop:~$
yay! I'm me again! are these my hands? boy, it's good to have them back! when you are the root user, you are not requested to provide a password when switching to another user. I have problems with that, so I can't give an example. For information about performing administrative tasks, please see the RootSudo page.
pwd – present working directory. general description: this is used to display the path of the directory you are looking at onto the console.
how to use it: just open the console and type in pwd it should look similar to this: yman@yman-laptop:~$ pwd /home/yman
the first line is what you type in (the “yman@yman-laptop:~$” is already there, you just type in the “pwd”). the second line is the output.
cd – change directory. general description: it changes the currently viewed directory to the directory specified.
how to use it: type the command and then the path of the directory you want to open. if it's a subdirectory of the directory you are at, just type / followed by the name of the directory. if a name has spaces in it, wrap it in quotation marks. for example: yman@yman-laptop:~$ cd /home
example 2: yman@yman-laptop:~$ cd “my documents”
by typing “cd /” you move to the main or root or something like that directory.
ls – list (contents of pwd directory). general description: lists all files and subdirectories of the given directory.
how to use it: type in ls, followed with the path of the directory whose contents you want to see. if you don't give the path it just lists the contents of the pwd. you could add the attribute -l in order to get more detailed information. examples: yman@yman-laptop:/$ ls bin cdrom etc initrd lib media opt root srv tmp var boot dev home initrd.img lost+found mnt proc sbin sys usr vmlinuz
the first line is the users input. the two others are the output, listing the subdirectories and files of my / directory. example 2: yman@yman-laptop:/$ ls home zman yman
in this example, I gave the command to display the contents of the subdirectory called “home”. example 3: yman@yman-laptop:/$ cd home/yman yman@yman-laptop:~$ ls /lib brltty libcidn-2.3.6.so libncursesw.so.5 libresolv.so.2 dhcp3-client libcidn.so.1 libncursesw.so.5.5 librt-2.3.6.so discover libcom_err.so.2 libnsl-2.3.6.so librt.so.1 evms libcom_err.so.2.1 libnsl.so.1 libSegFault.so firmware libconsole.so.0 libnss_compat-2.3.6.so libselinux.so.1 grub libconsole.so.0.0.0 libnss_compat.so.2 libsepol.so.1 init libcrypt-2.3.6.so libnss_dns-2.3.6.so libslang.so.2 iptables libcrypt.so.1 libnss_dns.so.2 libslang.so.2.0.5 klibc-t2jM36h7OcxUNTDzncfER2p7kd4.so libc.so.6 libnss_files-2.3.6.so libss.so.2 ld-2.3.6.so libctutils.so.0 libnss_files.so.2 libss.so.2.0 ld-linux.so.2 libctutils.so.0.0.0 libnss_hesiod-2.3.6.so libsysfs.so.2 libacl.so.1 libdevmapper.so.1.02 libnss_hesiod.so.2 libsysfs.so.2.0.0 libacl.so.1.1.0 libdiscover.so.1 libnss_nis-2.3.6.so libthread_db-1.0.so libanl-2.3.6.so libdiscover.so.1.0.0 libnss_nisplus-2.3.6.so libthread_db.so.1 libanl.so.1 libdl-2.3.6.so libnss_nisplus.so.2 libusb-0.1.so.4 libatm.so.1 libdl.so.2 libnss_nis.so.2 libusb-0.1.so.4.4.2 libatm.so.1.0.0 libe2p.so.2 libpamc.so.0 libutil-2.3.6.so libattr.so.1 libe2p.so.2.3 libpamc.so.0.79 libutil.so.1 libattr.so.1.1.0 libevms-2.5.so.0 libpam_misc.so.0 libuuid.so.1 libblkid.so.1 libevms-2.5.so.0.4 libpam_misc.so.0.79 libuuid.so.1.2 libblkid.so.1.0 libext2fs.so.2 libpam.so.0 libwrap.so.0 libbrlapi.so.0.4 libext2fs.so.2.4 libpam.so.0.79 libwrap.so.0.7.6 libbrlapi.so.0.4.1 libgcc_s.so.1 libparted-1.6.so.13 linux-restricted-modules libBrokenLocale-2.3.6.so libhandle.so.1 libparted-1.6.so.13.11.1 linux-sound-base libBrokenLocale.so.1 libhandle.so.1.0.3 libpcprofile.so lsb libbz2.so.1 libhistory.so.5 libpopt.so.0 lvm-200 libbz2.so.1.0 libhistory.so.5.1 libpopt.so.0.0.0 lvm-default libbz2.so.1.0.3 libiw.so.28 libproc-3.2.6.so modules libc-2.3.6.so libm-2.3.6.so libpthread-0.10.so security libcap.so.1 libmemusage.so libpthread.so.0 terminfo libcap.so.1.10 libm.so.6 libreadline.so.5 tls libcfont.so.0 libncurses.so.5 libreadline.so.5.1 udev libcfont.so.0.0.0 libncurses.so.5.5 libresolv-2.3.6.so
here, I moved to one directory and then gave the path to another directory. note that I used the “/” before naming the directory I want to view. if I were to be viewing a subdirectory of the pwd, I wouldn't add the ”/” before the directories name. also take notice that when running these commands in the terminal the results are much prettier. example 4: yman@yman-laptop:~$ ls -l total 12 drwxr-xr-x 2 yman yman 4096 2006-07-31 20:23 Desktop drwxr-xr-x 4 yman yman 4096 2006-07-30 13:34 drive_c lrwxrwxrwx 1 yman yman 26 2006-07-28 09:41 Examples -> /usr/share/example-content drwxr-xr-x 3 yman yman 4096 2006-07-31 20:20 my documents
this lists the contents of the pwd, in this case /home/yman, with more details then when using the simple “ls” command. example 5: yman@yman-laptop:~$ ls -l /home/zman total 0 lrwxrwxrwx 1 zman zman 26 2006-07-28 16:15 Examples -> /usr/share/example-content
this last example of the “ls” command shows how to write the more detailed command and specify a directory.
more – general description: displays output in small portions and allows you to scroll downwards.
how to use it: you can either type “more” and then the name of a text file to be displayed, or you can pipe it. piping is when after you write a the command, but before issuing it, you add pipe symbol at the end of the line followed by a command you want to use with the first one. a pipe symbol looks like this: |. you can type it by pressing shift+\.
example 1: yman@yman-laptop:~/my documents/linux commands$ more newbe_to_newbe_guide_to_linux_commands-a_documentation_of_a_learning_proccess.txt
this is supposed to be one line. anyhow, it demonstrates the first use of more that I listed. this command displays one screen-full of text from the specified file. you can scroll down one line using “return” key, or scroll down one screen by pressing “space”. to exit press shift+q. to search a displayed text downwards, type “/” followed (without spacing) by the search word. example 2: /more
when typing “/”, the word “more(%somenumber)” thats at the bottom would be replaced by the characters your typing. example:
the first few lines of the results are: ...skipping general description: lists all files and subdirectories of the given directory.
how to use it: type in ls, followed with the path of the directory whose contents you want to see. if you don't give the path it just lists the contents of the pwd. you could add the attribute -l in order to get more detailed information. examples:
(my highlighting, it doesn't highlight it for you). the display scrolls downwards and the search word wold be somewhere near the top of the screen. to continue searching for the same word press “n”.
example 3: yman@yman-laptop:~/my documents/linux commands$ cd /lib yman@yman-laptop:/lib$ ls -1 | more
here I'm using piping. the result is that instead of an endless list that goes on forever I get a list of files the length of one screen, and I can scroll down on screen or one line at a time.
less – general description: an expansion of “more”. please read “more” before you read “less”, because I'm not going to repeat common commands.
allows you to both scroll up and down output text, search it up and down and jump to a specified line.
how to use it: just like “more”, you can either use it to open a text file or pipe output. you can scroll down text one at a time with “return” key or the “down” arrow key. you can scroll down one screen at a time with the space bar. you can scroll up one screen with Ctrl+b, and one line with Ctrl+B or the “up” arrow key. you could jump to a specified line by typing the number followed (without spacing) with the letter “g” or “G”. if you don't specify a number, a small g would send you to the first line, while a capitalized G would send you to your end. em, I mean the end. to search forward in the text type a “/” followed with the search word. to search backwards type a “?” followed by the search word. all found search words will be highlighted. to exit press Ctrl+q.