________ SWAT MAGAZINE ISSUE TWENTY-TWO: OCTOBER 1999 ________ / \______________________________________________/ \ / A quick guide to the UNIX command line \ / By qwaszx \ ----------------------------------------------------------------------- This file is basically a little guide for all those newbies out there who want to learn to hack UNIX/Linux. Knowing the system is essential to being able to hack it. So I decided to write a small guide for anyone wanting to learn the basics of UNIX. Anyway - on with the commands.... ls - view all files in a directory (same as dos DIR) cp {file1} {file2} - copies {file1} to {file2} mv {file1} {file2} - moves {file1} to {file2} rm {file} - deletes {file} (same as dos DEL) vi {filename} - edits {filename} (vi is a text editor) pico {filename} - edits {filename} (pico is an easy to use editor) man {command} - get help on {command} (reads the manual) cd {directory} - changes to {directory} cd .. - changes to the parent directory cd ~ - changes to your home directory cd ~fred - changes to freds home directory chdir {directory} - same as cd (changes directory) mkdir {directory} - creates a new directory rmdir {directory} - removes an EMPTY directory rm -rf {file/dir} - removes a file or dir (even full) WITHOUT ASKING who - who is on the system w - extended version of who who am i - shows who you are who is lame - :-) finger {user} - gets information on {user} ps - shows what programs you are running more {filename} - views {filename} pausing after each screen cat {filename} - views the contects of {filename} Thats just a few of the commands you will need to use - memorise that list. It will come in very handy when using UNIX. Files/Directories ----------------- Okay, so you are really new to UNIX with next to no DOS experience and you have been force fed windows all your life - I pity you... Anyway - you want some help with using files and directories. I assume you know what a file is, and that a Directory (or a folder in windoze speak) contains files and possibly loads of other directories ad inifinitum. ie. / |_ /etc <---------- Directory | | | |_ /etc/passwd <---------- File | |_ /usr <---------- Directory | |_ /home <---------- Directory | |_ /home/qwaszx/ <---------- Subdirectory Note: Unlike DOS, where directories are donted with a backslash (\), UNIX uses a Forward-slash (/) to seperate directory names. Do not get these confused. Now when you log into your UNIX shell account (or log in at home on your linux system), you usually start off in your HOME directory. This is the directory where all of YOUR files are stored (ie. email, web pages, hacking texts, SWAT magazine etc.) Each user has their own home directory which is usually stored under /home/username or /home/users/username. So for example if your username is fred, then your home directory will be: /home/fred (The only exception usually is when you are root, when your home directory is usually /root). Note that these locations are just guidelines, the system administrator may have placed you in some weird directory elsewhere on the hard drive (One place I know group users by the first letter of their username eg. /home/f/f-s and /home/q/qwaszx.) Now a shorcut for your home directory is the tilde sign or 'squiggle' as I usually call it (~), so typing in 'cd ~' (without quotes) would take you to your home directory. Copying, moving and deleting files ---------------------------------- Each of these examples will assume that you have a file in your home directory called test. If you don't, and want to try out these examples, then type in the following: cd ~ touch test You should now have a file in your home directory called test. Copying: To make a copy of a file you type cp Example: cp test test2 If you type that in and then type in ls, you should see that there are now 2 files in your home directory, the second an exact copy of the first. Moving/Renaming: Moving and renaming a file are generally the same thing, and are accomplished by using the same command: mv Example: mv test test2 This will rename the file "test" to "test2". The only difference between moving and renaming is that moving is when a file goes between directories, so to move "test" from your home directory into /etc for example, you would type: mv ~/test /etc/ These examples can be combined to move a file to a different directory and change its name at once. Example: mv ~/test /etc/passwd This would move your test file to /etc/passwd [NOTE: This is a very bad idea as it would probably make your system unusable] Deleting: For this you do rm Example: rm test This would get rid of the file test in the current directory. 'rm /etc/passwd' would delete the password file. Thats all for this month - I may continue this as a series if people want me to. Mail me if you are interested. =qwaszx= --- Written by qwaszx for SWAT Magazine Send comments, suggestions, praise to Send Flames to Standard disclaimer applies - I am not reponsible for what you do with this information, and for any inaccuracies. blah.. blah.. blah......