Some CLI Basics
From openSUSE
Introduction
A Command-Line Interface (CLI) is the traditional way to interact with an operating system. Many operating systems (even modern ones) have a CLI, such as DOS, OS/2, Windows, and Linux. A CLI mean is you type a specific commands into a command prompt to perform a specific action. Some things can only be done at a command-line and a lot of the time a command-line is quicker than the graphical way.
Legend
- ~ = users home directory
- / = Unix Delimiter symbol
How does a Linux command-line differ from a Windows command-line?
The first thing you will notice is that there is no drive letters in Linux like there are in Windows. Because Windows and DOS use drive letters, their command-line's start with the drive letter you're currently sitting on (eg. C:\> ). A Linux command-line will goto the current users home directory and will not have any drive letter. A command-line in Linux follows the user@host convention, because in a Linux based system disk drives and hard disk partitions are mounted on Linux's root partition. In normal directory's (these directory's are real directory's) and are not assigned any drive letters like each hard disk partition (and disk drive) would be in Windows.
The current directory concept
This concept is the very same in Windows, in that if for example you are currently sitting in the WINDOWS folder on drive C the command-line would look like this: C:\WINDOWS> Therefore WINDOWS is your current working directory because that's the folder (directory) you are sitting in. So you still need to remember which folder you are sitting in when using the command-line, regardless of which system you are using.
The relative and absolute path concept
Which ever folder you are currently sitting in, is the folder all commands you run will be applyed to. Let's say you are already sitting in the folder you want apply the particular command to, you would use a relative path and just type the file or folder name you want to modify in some way. An absolute path is the whole path to a file or folder, like for example the cp command's full path: /bin/cp This concept is the very same in Linux.
Command options/switches
Like in Windows, DOS as well as many other systems most Linux command-line commands have extra options one can use with them. Command options basically narrow or widen the scope of the command. In Windows and DOS (as well as many other systems) command options are usually indicated by the forward slash eg. dir/w
Most Linux and Unix commands are indicated by a space and then - , for example ls -l which lists all files and folders with security permissions.
A Linux command-line (from a terminal window) and a Windows XP command-line
- A Linux terminal shell window - current working directory/folder is my
homedirectory
- A Windows command-line - current working directory is the
Jamesfolder
A table of some basic Windows and Unix/Linux commands
How to bring up a Linux command-line
- Press ALT+CRTL+F1 and login to the virtual terminal
- In KDE goto the K Menu (SUSE menu) > Applications > System > Terminal > Terminal Program
- In GNOME goto the GNOME Menu > Terminal
| | The following commands are not specific to openSUSE, therefore you will find them in most Linux/Unix distributions. Some of the following commands may also require root rights. |
| | Some commands only have an info page or Unix manual page and not the other, so just be aware of that. But most of them have both a Unix manual page and an info page. |
View Unix manual page of the command cp
Type:
View the info page for the command cp
Type:
| | These commands relate directly to dealing with the various files systems in use by Linux |
Listing files and folders
Type:
Create a directory named mydir
Type:
Copy a file named /bin/file to your home directory
Type:
Moving ~/mydir to ~/dir2/mydir
Type:
Renaming a file named file to file1
Type:
Delete the file named ~/file
Type:
Delete a directory named mydir that contains files
Type:
Display the full path to a command
Type:
View the full contents of a file named file
Type:
View the first 10 lines of a file named file1
Type:
View the last 10 lines of a file named file1
Type:
| | These commands are related directly to user's and groups |
Display currently logged in users
Type:
Add a user named bob
Type:
Delete a user named bob
Type:
Send a message to another user
Type:
|
Killing a process
Type:
| | get the process number from the top command |
Killing a process tree
Type:
View current processes that are running
Type:
View current system runlevel
Type:
Change to runlevel 1
Type:
or
type:
|
Get Information About Kernel Modules
Type:to get list of all kernel modules installed on the system.
Type:
Replace module-name with the real name of kernel module, without leading path and extension, that you want to get information.
I.e: to get information about kernel module for modem sierra type:
list all USB devices
Type:
list all PCI devices
Type:
| | This section is commands for various Linux media players and other multimedia software |
Use mplayer to play an audio file named "audio.mp3"
Type:
Clear the screen
Type:
View bash history
Type:
| | Specific commands means that you may not find the following commands in some other Linux/Unix distributions. Some of the following commands also may require administrator rights to be run. |
Install an RPM software package
Type:
or
type:
Run the command-line version of YaST
Type:
See Also
- http://en.wikipedia.org/wiki/Command-line_interface
- http://www.think-lamp.com/2008/11/very-useful-linuxunix-commands/
- http://books.google.com/books?id=OmnF5MGRNn8C&dq=in+the+beginning+comand+line&pg=PP1&ots=XTN1PFZuJw&sig=S-k5FfNtMXcbbqjqUiqSaMyII8Q&hl=en
- http://en.wikipedia.org/wiki/Shell_script
- http://en.wikipedia.org/wiki/Path_(computing)


