![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
October 8, 2025 Wednesday 12:36 AM
|
Introduction to Linux
It's simple really, a touch of DOS done the right way, a windows GUI for those not comfortable in the drivers seat,
and the power of the Sun, pun intended.
How do I log in?
At the login prompt, enter your username if you have one. Otherwise type root. You'll then be prompted for a password, so enter that too.
linuxhost login: myusername
Password: mypassword [myusername@linuxhost ~] $
How do I get a directory listing?
[myusername@linuxhost ~] $ ls
The ls (list) command will show all the (non-hidden) files in the current directory. Very little information is
presented, although the color does mean something on some Linux releases. Regular files are normally in a black font, subdirectories are blue by default. Executables (files with the execution bit set) are light green. There are other colors, all described in /etc/DIR_COLORS.
anaconda.ks.cfg Desktop install.log minicom.log sysstatus tmp And yes, Linux is case-sensitive. We'll expand on directory listings later in this page.
How do I change directories?
[myusername@linuxhost ~] $ cd newdir
The cd command will get you where you want to go. If you type it without a directory argument
you'll wind up in your home directory. This is both a blessing and a curse, so be careful.[myusername@linuxhost newdir] $ Notice that the last string in the brackets changed to the new directory name, this is a good way to keep up with where you are. Also, the '~' in the same position only means you are in your home directory. You DOS and windows guys will need to reprogram your fingers to use the forward slash '/' as a directory separator instead of the backwards DOS method '\'.
How do I find out how a command works?
Look at its manual page.
[myusername@linuxhost ~] $ man ls
This will give you the manual page for the ls command.
The man pages are arranged in groups based on the type of function or programming where it applies.
The command above pulls the man page from section 1 by default. Section 1 is the user's section.
Section 2 is the programmer's reference:
[myusername@linuxhost ~] $ man 2 chdir
will display the C language particulars for the chdir C function.
How do I found out what commands are related to an operation or device?
[myusername@linuxhost ~] $ apropos conf
This searches through the man page database and lists everything related to the keyword 'conf'. With many
commands you'll get a large list. The second column in the output tells you which section of the man pages
where the entry was found, (1) for user commands, (5) for configuration data, (8) for admin commands, etc.
File and Filesystem Permissions
Linux (and UNIX, BSD, Solaris) are all based on the idea that a file's owner, group, and everyone else have different access needs. The simple overview is that there are different permissions for reading a file, writing a file, and executing a file; and there are three user types with each of these three permissions. The file's owner can read, write and/or execute the file. Members of the file's group can read, write and/or execute the file. Everyone else can read, write and/or execute the file. Bring up a terminal shell on your desktop. Typically this will be a right-click on the desktop labeled something like "Open Terminal". When you see the prompt, type [bob@linuxhost ~]$ ls Desktop Documents Downloads file.txt ls -a to get a simple directory listing of all files and folders.
[bob@linuxhost ~]$ ls -a . .. .bash_history .bash_logout .bash_profile .bashrc Desktop Documents Downloads file.txt ls command doesn't show hidden files by default. Adding the option '-a' to the command tells ls to display 'all' files.
Let's expand a little. Let's look at a 'long' directory list. Type [bob@linuxhost ~]$ ls -al total 16 drwxr-xr-x 2 bob bob 4096 Jan 21 2009 . drwxr-xr-x 8 root root 4096 Jul 1 23:31 .. -rw------- 4 bob bob 2189 Oct 21 10:15 .bash_history -rw-r--r-- 4 bob bob 18 Oct 21 10:15 .bash_logout -rw-r--r-- 4 bob bob 141 Oct 21 10:15 .bash_profile -rw-r--r-- 4 bob bob 492 Oct 21 10:15 .bashrc drwxr-xr-x 4 bob bob 4096 Oct 21 10:15 Desktop drwxr-xr-x 4 bob bob 4096 Oct 21 10:15 Documents drwxr-xr-x 4 bob bob 4096 Oct 21 10:15 Downloads -rwxrwxrwx 4 bob bob 256 Oct 21 10:15 file.txt Note that they have 9 seperate (whitespace delimited) fields the way they are displayed. The first field (drwxr-xr-x) is the file permissions field. Don't worry about the filename yet, we'll get to that. There are 4 main components within the file permissions field. The first character 'd' tells us this points to a directory or a standard file '-' in the example, or several forms of special file not discussed here.
There next three fields are repetitions of the Read, Write, eXecute permissions described earlier. If the character shows a dash (-), then that permission is disabled for that collection of users. In the example above the owner (rwx) can read, write and execute the directory. The group and others are allowed only to read and execute. Key Takeaway: Remember the orders: Read-Write-eXecute, and Owner-Group-Everyone So who owns the file or directory? The 3rd and 4th fields both say 'root'. The 3rd field is the owner's name, and the 4th field is the name of the group. -rwxrwxrwx 4 root root 256 Oct 21 10:15 file.txt ^owner ^group So who am I and what group am I associated with? Sounds like a '60s flashback, but let's answer these age-old questions so you can find yourself. [bob@linuxhost ~]$ whoami bob [bob@linuxhost ~]$ groups bob apache Try this, and type in your root password when prompted: [bob@linuxhost ~]$ su - Password: [root@linuxhost ~]#
Several key things to notice. The prompt changed reflecting the new user (root) and the new current directory (~). The tilde means you are now in root's home directory. The dash (-) in the su command means to source the user's entire envinronment not just substitute the new user's identity. Had you left off the dash (-), the prompt would be So [root@linuxhost ~]# cat > myinfo.php <?php phpinfo(); ?> [root@www html]# . Congratulatiuons, you just created a new file using some high falutin' console redirection! Don't worry, let's go see what happened.
[root@linuxhost ~]# ls -al total 28 drwxr-xr-x 2 root root 4096 Jan 21 2009 . drwxr-xr-x 8 root root 4096 Jul 1 13:31 .. -rw-r--r-- 1 root root 20 Jul 1 14:22 myinfo.php This all begs the question, so what are the (.) and (..) in the filename entries for the directories? Simple, (.) is a generic shorthand for the current directory and (..) is shorthand for one directory level up. In this case, . refers to /var/www/html/ and .. refers to /var/www/ NOTE: These are always relative paths, they always refer to the current directory and one above it. You can't move somewhere else and expect . to refer to /var/www/html/ So what do we do with this lengthy discussion? Let's change the permissions to allow user 'bob' to write into the directory. There are several ways to enable bob, we could open up the permission and let anyone write into the directory, obviously less than optimal from a security standpoint. We could add bob to the root group, again, not a very secure thing to so. We could give bob permission to write to one single file, that's not too bad, so here's the way this will work. Let's move the new file to bob.php and give bob complete ownership of it. [root@linuxhost ~]# cp myinfo.php bob.php [root@linuxhost ~]# chown bob bob.php [root@linuxhost ~]# ls -al bob.php -rw-r--r-- 1 bob root 20 Jul 1 14:25 bob.php chown your-username bob.php .
So in closing, go back to the gedit editor and close the file without saving it. Open up the new file (
Bonus: (needs verified) How can I run a shell command to burn a CD?
[myusername@linuxhost ~] $ cdrecord -v -tao -data speed=8 \ dev=/dev/hdc image.iso
OR In Nautilus or the file browser:right click on "image.iso" and select "Write to Disc..." |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
all original content ©1994-2025 Yes, that means 30+ years on the web An exercise in truly free free-speech. No license required, no training wheels available. "When words lose their meaning, people will lose their liberty." -- Confucius vincit omnia veritas |