Linux can operate as a web, file, SMB (WinNT), Novell, printer, FTP, mail, SQL, masquerading, firewall, and POP server to name but a few.
It can act as a graphics, C, C++, Java, Perl, Python, SQL, audio, video, documentation, development workstation, etc.
Why Linux?
Linux is a good solution for developers that need a stable and reliable platform that has open-source code. It’s not a good system for beginning developers that want a simple GUI interface to a programming language, although Linux has many GUI software development interfaces.
Linux is ideal as a workstation also and offers many customizable features not found in any other platform. It makes a good platform for dedicated workstations that have limited functions like in an educational or laboratory environment.
Similar Posts: Reasons Why We Should Use Linux?
Command Line Basics
CLI stands for the command-line interface. It is a program that allows users to type text commands instructing the computer to do specific tasks.
Logging In To Your Account
Log into your system with the login name and password given to you. You will see something like :
<Bash>
Your system should always prompt you with the name of the shell (bash) and your login name. This is a customizable feature in the bash shell that you are now using. BASH is short for Bourne Again SHell. It was written by Steve Bourne as a replacement for the original Bourne Shell (represented by /bin/sh). This combines all the features from the original version of Bourne Shell, plus additional functions to make it easier and more convenient to use. It has since been adapted as the default shell for most systems running Linux.
Command Structure
Command -options Other parameters
First comes the command name, followed by options. Options are normally preceded by a dash or minus sign. There is always a space between the command and the dash. Some commands use no options at all. After the options comes any other parameters or
information that the command may need.
Help, Search, Info Tools:
env [-opts] [exp] Print environment or run a command with another environment.
find [path] [exp] Find files in path using exp
info keyword List info help pages containing keyword locate all files of name keyword in a database
man -k keyword List man pages with keyword (same as an apropos keyword) man command Display the manual for command
printenv Print environment variables (see set)
set [vars] Print/Set environment vars and functions
whatis keyword Search the whatis DB for keyword
whereis command Locate source/binary and manuals for command
which command Display path of a command
Text Manipulation Tools
awk| gawk [pgrm][file] Filter file by pgrm
cat file Display contents of a file without paging
clear Clears the screen. Same as Ctrl+L
grep pattern file Finds pattern in the file
head file List the first few lines of file more file Display & page the text file (See less)
sed [script] file Stream edit/filter file using a script
tail [-opts] file List the trailing lines of a file
tr chars1 chars2 file Change chars in chars1 to chars2
less file Display & page the text file
General Tools
cd dir Change cwd to dir (home if dir omitted)
chmod perms file Change file permissions of files
chown owner.group files change file owner and/or group
chsh Change the default shell
cp [-opts] f1 (f2|dir) Copy file f1 to f2 or directory dir
date Displays the date
kill pid Kills process ID pid
ln [-opts] Old New Link Old to New
login [username] Login to the system with UID username
lpr file Print file on the default printer
ls [file] Listing for file (cwd if file omitted)
mkdir dir Creates directory dir
mv file1 file2 Rename file1 to file2
passwd [-opt] username Change password
ps [-opts] Output a list of currently active processes
pwd List the current working directory
rm files Remove files
startx Start the X-Windowing system
tar [-opt][arch][file] Manage tar archives
telnet [host [port]] Connect to the remote host
uname [-opts] Output name and version number of OS
who List users logged into this system
xterm [-opts] Start a brand new X-terminal window
Must Read: What is Linux? Distributions, History, and File System
A command is a specific instruction given to a computer application to perform some kind of task or function.
In Windows, commands are usually entered via a command-line interpreter, like Command Prompt or Recovery Console.
Commands must always be entered into a command line interpreter exactly. Entering a command incorrectly (wrong syntax, misspelling, etc.) could cause the command to fail or worse, could execute the wrong command or the write command in the wrong way, creating serious problems.
There are many different kinds of commands, and many phrases that use the word command that probably shouldn’t because they do not actually command. It can be kind of confusing.
Below are some popular kinds of commands you might encounter.
Command Prompt Commands
Command Prompt commands are true commands. True commands are programs that are intended to be run from a command-line interface (in this case the Windows Command Prompt) and whose action or result is also produced in the command line interface.
DOS Commands
DOS commands, more correctly called MS-DOS commands, might be considered the “purest” of the Microsoft-based commands since MS-DOS has no graphical interface so each command lives completely in the command line world.
Don’t confuse DOS commands and Command Prompt commands. MS-DOS and the Command Prompt may appear similar but MS-DOS is a true operating system while Command Prompt is a program that runs within the Windows operating system. Both share many commands but they are certainly not the same.
Run Commands
A run command is simply the name given to an executable for a particular Windows-based program.
A run command is not a command in the strictest sense — it’s more like a shortcut. In fact, the shortcuts that live in your Start Menu or on your Start Screen are usually nothing more than an icon representation of the executable for the program — basically a run command with a picture.
For example, the run command for Paint, the painting and drawing program in Windows, is mspaint and can be run from the Run box or Search box, or even from the Command Prompt, but Paint is obviously not a command-line program.
Some other examples are a bit more confusing. The run command for Remote Desktop Connection, for example, is mstsc but this run command does have some command line switches that make opening the program with specific parameters very easy. However, Remote Desktop Connection is not a program designed for the command line so it’s not really a command.
Control Panel Commands
Another command you’ll see referenced that isn’t really a command is the Control Panel applet command. A Control Panel applet command is really just the run command for the Control Panel (control) with a parameter instructing Windows to open a specific Control Panel applet.
For example, executing this command opens the Date and Time applet in Control Panel directly.
control /name Microsoft.DateAndTime
You can execute this command from the Command Prompt, but the Control Panel is not a command-line program.
Recovery Console Commands
Recovery Console commands are also true commands. They are only available from within the Recovery Console, the command line interpreter is available only for troubleshooting problems and only in Windows XP and Windows 2000.
Pwd(Print Working Directory)
It Simply prints where you are currently working directory location. Open a command-line interface (also called a terminal, console or xterm) and type pwd.
yc@ubuntu:~$ pwd /home/yc
Cd(Change Directory)
You can change your current directory with the cd command (Change Directory).
yc@ubuntu:~$ pwd /home/yc
cd ~
The cd is also a shortcut to get back into your home directory. Just typing cd without a target directory, will put you in your home directory. Typing cd ~ has the same effect.
yc@ubuntu$ pwd /home/yc yc@ubuntu$ cd /etc yc@ubuntu$ pwd /etc yc@ubuntu$ cd ~ yc@ubuntu$ pwd /home/yc
cd ..
To go to the parent directory (the one just above your current directory in the directory tree), type cd .. .
yc@ubuntu$ pwd /usr/share/games yc@ubuntu$ cd .. yc@ubuntu$ pwd /usr/share
cd –
Another useful shortcut with cd is to just type cd – to go to the previous directory.
yc@ubuntu$ pwd /home/yc yc@ubuntu$ cd /etc yc@ubuntu$ pwd /etc yc@ubuntu$ cd - yc@ubuntu$ pwd /home/yc
Absolute and Relative paths
You should be aware of absolute and relative paths in the file tree. When you type a path starting with a slash (/), then the root of the file tree is assumed. If you don’t start your path with a slash, then the current directory is the assumed starting point. The screenshot below first shows the current directory /home/yc. From within this directory, you have to type cd /home instead of cd home to go to the /home directory.
yc@ubuntu$ pwd /home/yc yc@ubuntu$ cd home bash: cd: home: No such file or directory yc@ubuntu$ cd /home yc@ubuntu$ pwd /home
When inside /home, you have to type cd yc instead of cd /yc to enter the subdirectory yc of the current directory /home.
yc@ubuntu$ pwd /home yc@ubuntu$ cd /tyc bash: cd: /tuc: No such file or directory yc@ubuntu$ cd yc yc@ubuntu$ pwd /home/yc
ls
You can list the contents of a directory with ls
yc@ubuntu:~$ ls allfiles.txt dmesg.txt services stuff summer.txt yc@ubuntu:~$
ls -a
A frequently used option with ls is -a to show all files. Showing all files means including the hidden files. When a file name on a Linux file system starts with a dot, it is considered a hidden file and it doesn’t show up in regular file listings.
yc@ubuntu:~$ ls allfiles.txt dmesg.txt services stuff summer.txt yc@ubuntu:~$ ls -a . allfiles.txt .bash_profile dmesg.txt .lesshst stuff.. .bash_history .bashrc services .ssh summer.txt
mkdir
Walking around the Unix file tree is fun, but it is even more fun to create your own directories with mkdir. You have to give at least one parameter to mkdir, the name of the new directory to be created. Think before you type a leading /.
yc@ubuntu:~$ mkdir mydir yc@ubuntu:~$ cd mydir yc@ubuntu:~/mydir$ ls -al total 8 drwxr-xr-x 2 yc yc 4096 Sep 17 00:07 . drwxr-xr-x 48 yc yc 4096 Sep 17 00:07 .. yc@ubuntu:~/mydir$ mkdir stuff yc@ubuntu:~/mydir$ mkdir otherstuff yc@ubuntu:~/mydir$ ls -l total 8 drwxr-xr-x 2 yc yc 4096 Sep 17 00:08 otherstuff drwxr-xr-x 2 yc yc 4096 Sep 17 00:08 stuff yc@ubuntu:~/mydir$
mkdir -p
The following command will fail because the parent directory of threedirsdeep does not exist.
yc@ubuntu:~$ mkdir mydir2/mysubdir2/threedirsdeep mkdir: cannot create directory ‘mydir2/mysubdir2/threedirsdeep’: No such file or directory
When given the option -p, then mkdir will create parent directories as needed
yc@ubuntu:~$ mkdir -p mydir2/mysubdir2/threedirsdeep yc@ubuntu:~$ cd mydir2 yc@ubuntu:~/mydir2$ ls -l total 4 drwxr-xr-x 3 yc yc 4096 Sep 17 00:11 mysubdir2 yc@ubuntu:~/mydir2$ cd mysubdir2 yc@ubuntu:~/mydir2/mysubdir2$ ls -l total 4 drwxr-xr-x 2 yc yc 4096 Sep 17 00:11 threedirsdeep yc@ubuntu:~/mydir2/mysubdir2$ cd threedirsdeep/ yc@ubuntu:~/mydir2/mysubdir2/threedirsdeep$ pwd /home/yc/mydir2/mysubdir2/threedirsdeep
rm
rm command is used to delete a file or a directory.
yc@ubuntu$ rm directory or file name
rm -p
similar to the mkdir -p option, you can also use rm to recursively remove directories.
yc@ubuntu$ rm -p mydir2/mysubdir2/threedirsdeep
There are several types of files in Ubuntu Linux :
Regular files
they contain data, for example, text files, executable files or programs, input in or output out from a program, and such. Directories
are files/folders that are lists of other files. Special files
this is the mechanism used for input and output. Most special files are in /dev. Links
this is a system to make a file or directory visible in several parts of the system’s file tree. Domain sockets
this a special file type similar to TCP/IP sockets in windows. It will provide inter-process networking that’s protected by the file system’s access control.
Pingback: Linux File & Directory Permission - Youngster Company
Pingback: Linux User & Group Management - Youngster Company