Showing posts with label about linux. Show all posts
Showing posts with label about linux. Show all posts

List Files and Folders with Linux ls Command

The Linux ls command is used to list files and folders in a directory. There are tons of options to use on the ls command. I will not cover every single option that you can use with the linux ls command. I will cover the most common options for the ls command. If you don’t find what you are looking for in this Linux tutorial then I would recommend running man ls and reading the man pages for the ls command.
The usage for the Linux ls command is: ls [options] [file|directory]
You can use the ls command without any options or as many options as you like.
If you just run ls with no options it will output the list of files in the current working directory in alphabetical order. So if you are in $HOME (which is the system variable for your home directory ( /home/username ). This will also not output any .* files or directories ( files or directories that start with . as they are hidden files|directories ).
Now if you want to list all files and folders in a directory you can use ls -a or --all option. This option will output all files and folders including the files and folders that match .* ( your hidden files and folders ). You can also use ls -A or ls --almost-all which will output all files|directories except for ./ and ../ ( which ./ is current working directory, ../ is your parent directory ).
Another common option for ls is using ls -b or ls --escape which will escape any special characters like spaces. This is more useful if you can not figure out which characters need escaped or if you are writing a script that needs the characters escaped.
ls -l will output the files and directories in long list format. Which means ls -l will output your file and directory permissions, hardlinks or entries, user, group, size (in bytes), month, date, time, filename|directory name.
ls -h will display the output sizes in human readable form, the highest available measurement. ( 1K 1M 1G.. etc ). This option has to be used with an option that outputs size as well. So either ls -s or ls -l but you would combine the options, ls -lh or ls -sh will work.
You can combine a number of options for ls to get the results you want, ls -lha will display the output of all files and directories in long list format with the sizes being human readable aka the highest measurement available.
You can also pass the output onto other commands using a pipe | so that you can alter the results more to specific needs. For example if you want to just see the sizes of files, and not filename or directory names: ls -sh | awk '{print $1}' will do this for you. If you wanted to display just the permissions of the files and directories, you could use ls -l | awk '{print $1}' which will give you those results. If you want more information on scripting like this I will be covering this in another section.
I hope this beginner Linux tutorial on the Linux ls command has helped you accomplish what you need and also give you a better understanding on how the ls command works. Continue reading through the beginner Linux tutorial website for more Linux tutorials!

Linux File Info Command

The Linux file command is a pretty basic command in Linux that will output the file type information onto your screen. There are quite a few options for the Linux file info command, but I only use maybe 2 of the options on a regular basis. With Microsoft Windows it will always think that the extension of he file determines the file type. If you have a file named filename.txt Windows will automatically think this file type is a text file, when it could actually be a pdf file with a bad extension on it! Now Linux on the other hand, if you come across a file that has a bad extension on it, you can run file filename.txt and it will output: filename.txt: PDF document, version 1.4 or whatever version of the pdf format it actually is.
The main options of the file command that I use is file -f [filename], where [filename] would be a standard text file with a list of files you want to have checked. If using this option you will want [filename] to have 1 filename per line.
The other option I use often isn’t really an option on the file command, but is a short script. You can run file `ls` and it will output the file types of all of the files that the ls command outputs normally, which will be all of the files listed in your current working directory.
I hope this Linux tutorial for beginners has helped you learn more about the Linux file type information command. As always if you have any questions or comments on this Linux tutorial you can leave them below, or you can use our Linux forum.

mkdir How to Create a Directory in Linux

For those of you wanting to know how to create a directory in Linux using the command line interface or Linux shell, you will want to read this Linux beginner tutorial on how to use the Linux mkdir command. The Linux command mkdir is used to make directories in Linux. There aren’t many options I use with this Linux command either. There is only 1 option I use with the mkdir command on a regular basis.
The usage for mkdir is very simple mkdir [options] [directory].
Just remember when running mkdir that you are creating directories from the current working directory, unless you specify another path. So if I am in /home/max/ and I want to make a directory called images I would run mkdir images which will create the directory images in /home/max/ so now my complete path for images is /home/max/images/. Now if I was in /home/max/files/ and still wanted to create /home/max/images/ I could run mkdir ../images which ../ is your parent directory. I could also type in the full path on the command line by running mkdir /home/max/images to get the same results.
The option I use on a regular basis for the mkdir command is mkdir -p which will allow you to create parent directories if they don’t already exist. For example if /home/max/images/ didn’t already exist and I wanted to make a directory /home/max/images/family I could either make each directory individually by running mkdir /home/max/images then run mkdir /home/max/images/family. I could also script this slightly all in one command line, yet 2 separate commands by running mkdir /home/max/images && /home/max/images/family. So either way still having to type out many commands. Now instead of typing all the extras, i could simply run 1 mkdir command to create the parent directories as well using the mkdir -p option. Which I would then run mkdir -p /home/max/images/family and this will create /home/max/images and also /home/max/images/family as well!
I’ve also seen a lot of people asking how to make directories a through z with Linux? Well my first thought was to try mkdir [a-z], but unfortunately this will just create a directory named [a-z]. So in Linux to make directories a through z you have to make a small script type command. Here is the command you can run to create directories a through z, if you are wanting to organize mp3s for example: perl -e 'for (a..z) {system("mkdir $_")};'
SHELL NOTE: For anyone wondering in the example command line where I used mkdir /home/max/images && /home/max/images/family what the && does, the && on a command line separates shell commands and only runs the next shell command if the first Linux shell command ran successfully without any errors. So if for some reason mkdir /home/max/images failed, the shell would not run the next shell command mkdir /home/max/images/family.
As always thank you for reading this information on the Linux mkdir command for creating new folders and directories in Linux via the command line interface. If you have any friends you would like to teach how to run Linux, send them here to the beginner linux tutorial, where we will hopefully turn them into advanced Linux users or at least Linux users so they can get rid of that evil Microsoft product they call an operating system!

Change Directory using cd Linux Command

In this Linux tutorial for beginners, you will learn how to change directories in Linux using the cd command. The Linux cd command is very easy to use. There are a couple options you can use with the cd command, but I won’t cover them as I hardly ever use them. I will show you how to use some common variables with the Linux cd command though.
When using the Linux cd command to change directory, the syntax of the Unix cd command is cd [directory]. Pretty easy to remember right? So if you are wanting to change your current working directory to your home directory, you can run cd /home/max as max is my username. With the cd command if you do not specify any directory it will automatically change directory to your home, so just running cd in the Linux shell will take you to your home directory as well. Another way to get to your home directory in Linux is using the home variable $HOME. So if you type cd $HOME you will be taken to your user’s home directory as well.
You can also use the $HOME variable as part of a path. Say if you wanted to change directory to /home/max/images/family you could run cd $HOME/images/family which will take you to /home/max/images/family but of course your $HOME not mine!
Some other common uses of the Linux cd command is to change directory to the parent directory. To do this you could use cd ../ which will change directory to the parent directory of the active directory you are already in. You can also use ../ as part of your path, so say my current working directory is /home/max/images/family and I want to change directory to /home/max/images/friends you have 2 options. You can run the cd command with the full path: cd /home/max/images/friends or your other option is to use the ../ parent directory as part of your path like this: cd ../friends/ since I was already in /home/max/images/family the parent directory is /home/max/images/
One more common thing I see some people asking is how to change to a directory with a space in the shell. When you are in the command line interface a space is a special character so you will have to escape it using a backslash \ I usually try not to make any filenames or directory names with any special characters in them, but if you do have a directory named say Linux Stuff you would use cd Linux\ Stuff to change directories.
You can also use the cd shell command to change directory as part of a script. For example if I was wanting to make a script that would change directory to /usr/local/games/quake3 and then run ./quake3 since the quake3 game needs your shell to be in /usr/local/games/quake3 as the working directory for the game to run properly, you could run cd /usr/local/games/quake3 && ./quake3 which you can save to a file in /usr/bin/quake3 so when you run quake3 the shell script will cd /usr/local/games/quake3 and if that runs with no errors the shell script will then also run ./quake3
At the moment I am pretty tired, so the quake3 game was the only thing I could think of off the top of my head that you would want to script the Linux cd command.
I hope this cd Linux tutorial for beginners has helped you learn more about the Linux shell command cd so you can change directories easily using the Linux shell. Remember to come back and visit Beginner Linux Tutorial for more Linux tutorials for beginners as this site will always be adding more Linux tutorials.

cp Linux Copy Command

The Linux copy command is cp! Pretty simple right? There are many ways to use the Linux cp command. There are also many options for the cp command, but I usually only use 2 of them daily. The other options for Unix cp command I hardly use because there are other commands or programs in Linux that do a much better job for accomplishing the same tasks. So for the other options for the Linux copy command, I will not cover them in this tutorial. If there is some specific cp command usage or syntax you want to know, please let me know and I will add it to this Linux tutorial.
The 2 options for the Linux cp command that I will cover is how to copy file recursively and also how to copy files in Linux only if the source file is newer than the destination file.
First the syntax for using the Linux cp command is cp [options] [source] [destination], where [source] or [destination] may be a file or a directory.
The main option for the Linux cp command that I use is coping a directory recursively. To do this you would use cp -R [source] [destination], cp -r [source] [destination], or cp --recursive [source] [destination]. I usually am lazy and just use the shortest easiest keystroke, cp -r [source] [destination].
Coping a directory recursively means copying the entire folder, including it’s contents. For example if I was wanting to copy the directory /home/max/images/family/ and all of the directories and files inside of it to /media/backup_drive/, I would run cp -r /home/max/images/family /media/backup_drive/
Now if I was not wanting to copy the entire directory and just wanted only the *.jpg files, I would not need the -r option. I would simply run cp /home/max/images/family/*.jpg /media/backup_drive/family/jpeg_files/ which * is a wildcard, so anything.jpg will be copied. Yes, that is a bad example as that is a very ugly directory structure, but again it is about 4:30am and I should really be sleeping!
There are much better ways to backup your data in Linux than using the cp command, that is the only example I could come up with at the moment. In another Linux tutorial I will cover how to backup your files in Linux using a lot more efficient methods.
The next option that I use from time to time on the Unix cp command is cp -u [source] [destination] or cp --update [source] [destination] which will only copy files if the source files are newer than the destination files, or if the destination files do not exist.
For an example of the Linux cp -u command I am wanting to copy files from my website and back them up, but I only want to copy the files that are newer, to save CPU usage and drive writes, no use in overwriting files that are the same or older right? So I will run cp -u /home/max/htdocs/* /media/backup_drive/htdocs/
If you are wanting to copy hidden files and folders in Linux using the cp command, the first thing people will think of is cp -r .* /media/backup_drive/max/hidden_config_files/ but this will actually match ./ and ../ as well, which will copy all files in the current working directory, and also copy all the files from the parent directory. So to copy only hidden files in Linux, you would want to run cp -r .[a-z,A-Z,0-9]* /media/backup_drive/max/hidden_config_files/ this way it will only match files that start with a . and the next character is a-z, A-Z, or 0-9 and everything after that being a wildcard.
I hope this Linux tutorial on the Linux cp command for beginners has helped you understand how to use the Unix cp command while in the Linux Command Line Interface.

How to Move Files in Linux mv Command

If you are wanting to know how to move files in Linux, you will need to use the Linux mv command. There are a few different options you can use with the Linux mv command, but I normally don’t use them. I do use the Linux mv command along with other commands to accomplish some tasks though. If you wanted to get information on the other options for the Linux mv command, remember you can always run man mv in a bash shell prompt.
The usage of the Linux mv command to move files around on your file system is much like the Linux cp command, but the source will no longer exist. To use the mv command in Linux shell, just run mv [source] [destination].
So for example I am making a new account on another Linux computer. I want to move my home directory to the new Linux computer. So first I setup nfs and mount my new Linux computer’s /home directory on my old Linux computer. Now I will run mv /home/max /mnt/home/ so all of my files move to my new Linux computer. This is just an example as I would most likely use rsync Linux command to do this. Which I will go over in another Linux tutorial.
I have also seen a few Linux beginners having trouble moving files in Linux that have special characters in them. So to move files with special characters in Linux you will simple escape the characters that hold special meanings, like a space, (, or ). So for example I have a file named DSC06540 (New LCD TV).JPG this is an ugly filename but to move this file from my compact flash drive on my camera to my /home/max/images/electronics directory, I would simple escape all the special characters with a \ like this mv /media/CF/DSC06540\ \(New\ LCD\ TV\).JPG /home/max/images/electronics/
Another command I use quite often with the mv shell command is find. I can have find search for files on my computer and move the files to a new location. To do this there are 2 methods you can use, one method of using Linux find to move files is a small script, for example if I want to move all my php files to /home/max/htdocs/ I would run this: for i in `find *php`; do mv $i /home/max/htdocs; done.
Method 2 that uses Linux find command to move files in Linux is using the -exec option of find to execute mv. This command was brought to my attention a few days ago by another Linux user, and it is much faster than my method. Using the same example to move my php files, but using this method, you will run: find *php -exec mv {} /home/max/htdocs \; which is a lot less to type!
You can also change your find options any way you prefer to search your hard drive for the files you are looking for. Which I will go over in another Linux tutorial.
As you can see it isn’t hard at all to move files and folders in Linux shell prompt at all. As always I hope this Linux tutorial for beginners has helped you learn more about the Linux mv command. I hope you come back and find more help on Beginner Linux Tutorial.

How to Delete in Linux Terminal rm Command

Many Linux users get confused when they are in a Linux terminal and trying to delete files of folders. So in this Linux tutorial, I will cover how to delete files in Linux terminal! The Linux delete command is another basic command that is used everyday while in a Linux terminal. There are only 2 options that I use on a regular basis with the Linux rm command.
The usage of the Linux rm command is rm [options] [file|dir]. The 2 options I use most is rm -r [dir] and rm -f [file]. Now to explain these options for the Linux delete command and also give you some examples on how to remove a file with Linux.
The rm -f [file] option is if you are wanting to force a file to be removed. This will not ask you “are you sure you want to remove [file]“. It will just delete the file regardless. So use this option for the Linux rm command only if you know you want all of the file(s) deleted.
Now the rm -r [dir] option is if you are wanting to delete a directory in Linux. The rm -r option is to specify to remove recursively, meaning a directory and it’s contents.
You can use these 2 options for the Linux delete command together as well. You could use the command rm -rf [dir] to delete a directory forcefully and recursively. DO NOT be fooled into running rm -rf /, rm -rf /* as this will remove all of your files and folders. Some people may come off as they are trying to help you with Linux and be a dick and tell you to run rm -rf /* which you can then say bye bye to your files and folders.
You can also use rm in a script type command after a pipe | so you can delete filenames of the output. You can also use rm to remove files that are produced from another command or script. Here is an example of how to remove a file found after grep in Linux. Say if you have a folder /home/max/images/family and in this directory you have 20 images that have the word copy in the title because you accidentally highlighted these 20 files, went to drag them into another folder in a GUI, and let go too early and created copies. So now you want to remove these copies, you would first cd to that directory cd /home/max/images/family now you can run rm -f `ls | grep copy` which will remove all the files that ls | grep copy matches. This same process could be done easier by running rm -f *copy* instead, but these are just examples.
I hope reading this Linux tutorial on the Linux rm command has taught you more than you already know and that you can continue reading through this Beginner Linux Tutorial website and learn even more about the Linux operating system! Have a great day and remember DO NOT run rm -rf /* or any variation of it. I will write a section on Beginner Linux Tutorial explaining more of the commands that can harm your system to watch out for when people are trying to help you with Linux so that you will not be a victim of this. If you are unsure if a command will harm your system, you can always do a quick reference check by searching the net for that command, or even looking at the man pages for that command to see what it is that command/options will do. You can read your manpages by typing man [command] like man rm will bring up the manual for the Linux rm command.

Linux grep Command

The Linux grep command is used to extract lines of data from files or extract data from other Linux commands by using a pipe. When using the Linux grep command, there are many ways you can extract or print lines. You can use standard text to grep or you can use regex patterns. When using regex patterns you can use basic regular expression (BRE), extended regular expression (ERE), or even a Perl regular expression!
There are many different grep options you can use in the grep syntax. I myself only use a few options with grep on a regular basis. The basic grep syntax is grep [options] [pattern] [file|files].
grep quick reference guide:
You can use grep -R, grep -r, grep --recursive, which will allow you to have grep parse files recursivley into other directories.
If you are working with code, or just want the output lines to be numbered you can use grep -n or grep --line-number.
Another option I use on a daily basis with grep is grep -i or grep --ignore-case, which will ignore case on both the input file, and the pattern. by default grep is case sensitive, so you have to use this option if you do not want it case sensitive.
If you are wanting to extract multiple patterns from your file, you can use grep -e which can be used multiple times to extract multiple patterns from your file. So if you are wanting to grep two different strings from one file in Linux, you could do grep -e firstpattern -e secondpattern /home/$USER/file.txt.
Here are some grep examples of using the Linux grep command:
If I had a plain text file called phone-book.txt, that had phone numbers listed in this order: First Name Last Name - Street Address - Phone Number
Now I want to get Brandon Stimmel’s phone number. I could run grep Brandon\ Stimmel phone-book.txt and grep would print Brandon Stimmel - 100101 Digital Ave. Tech, Ohio 44333 (330) 222-7222. Notice I used Brandon\ Stimmel, I did this because you can not use a space on the command line, or it will be parsed as the next section of the command, which grep Brandon Stimmel phone-book.txt without the \ would try to extract Brandon from the file Stimmel, which doesn’t exist. So remember to escape your spaces with a \ if you are using them in your pattern/search string.
For another example, if I want to bring up who owns the phone number (330) 222-7222 as it showed up on my caller ID, but I forgot who’s phone number it was, I can do grep \(330\)\ 222-7222 phone-book.txt which would again display: Brandon Stimmel - 100101 Digital Ave. Tech, Ohio 44333 (330) 222-7222.
You can also grep for just the last name, say if you are having a family reunion and you want to bring up all of the people with the last name of Stimmel. grep Stimmel phone-book.txt this will bring up every person in phone-book.txt that has the last name of Stimmel.
You can also pipe data to grep or pipe data from grep to use it in a bash script. Say if you are wanting to do the above example that you found a phone number and forgot who’s it was, but you don’t want to show the entire line with name, address, and number, you just want the name and only the name. grep \(330\)\ 222-7222 phone-book.txt|awk '{print $1" "$2}' which will output Brandon Stimmel. The grep part of this code will output the full string, then we pass that data onto awk which we used it to print only the first and second fields.
Well that’s it for the grep tutorial, for now anyways. As always, thank you for reading our Linux Tutorials and I hope you find these Linux Tutorials very helpful! Remember to bookmark Beginner Linux Tutorial so you can always come back and find more helpful Linux Tutorials!

Linux Web Hosting Vs Windows Hosting Plan

If you are wanting to build a website, you are probably wondering web hosting, Linux or Windows? I’m going to tell you right now, you want a Linux web hosting service! Here are some reasons why you want to have a Linux web hosting service instead of a Windows web hosting service.
The Linux operating system is more stable! This means that the computer that is serving your website to people every day, will not crash as often as Windows. If you are making money from your website selling products or services, you don’t want your website down at all. If your web site goes down, you can’t make any sales!
Linux operating system is free! So the web hosting company that owns all these web servers don’t have to pay another $300 to put Windows on each server. Which in turn will pass a slight savings onto you!
Linux is also built for networking and multitasking. So it can handle more people using the server at the same time without any problems. So if I had a server running Linux I could have 1,000 different customers using this same server. If I take this same exact server and I put Windows on it, I may only be able to have about 500 different customers using the same server. So again it’s cheaper for the Linux web hosting service so they don’t have to buy as many servers. Remember more servers is more money they have to spend on the servers themselves and also the electric to run that server. So again, you get a little bit of these saving passed onto you!
Linux servers are also more secure! There are many ways Linux is more secure, but the main reasons here, is account security! Your account is safer from hackers if your web hosting service is using Linux. Your customers credit cards and such are safer from attacks. Also your website is safer, so attackers don’t break your website, change your website, or even steal your files!
Linux can not get computer viruses! So your account will be safe from computer viruses ruining your data, stealing customer username, passwords, credit card numbers, etc.
So if you are wanting to check out some Linux web hosting services, below are some Linux web hosts that Beginner Linux Tutorial recommends:
NOTE: If you want full details of each Linux web host please check out our Linux Web Hosting section!

Linux more and less Commands

The Linux commands more and less are similar to cat, but with more and less you can scroll the file instead of showing the enter file at once. So if you have larger files you want to view that are longer than your screen or terminal then you can use more or less commands instead of cat.
I would suggest using less more often than more as the Linux less command can load files to the screen faster. If you do more somefile.txt the entire file must be read before it will start displaying on your screen. If you use less somefile.txt the contents of somefile.txt will be displayed as they are read from the file, so you don’t have to wait until the entire contents are read before you can see it!
Another reason I would suggest using the Linux command less more than the Linux command more is because with less command you can scroll up in the file as well as down, where with the Linux command more you can only scroll down the file. If you pass something with more you have to quit, run the more command again, and hope you don’t pass what you were looking for again.
The syntax for more is like most Linux commands: more [OPTIONS] [filename]. The sytax for less is the same: less [OPTIONS] [FILENAME].
The only options I use normally with less is less -N [FILENAME] which will print line numbers before each line. The only options I use on more is more +[number] [FILENAME] which will start you on line [number].
Now for some examples of more.
If I wanted to view file phone-numbers.txt to write them down on paper, or enter into my cellphone, I could run more phone-numbers.txt and hit enter to scroll down after I have already entered the information on my cellphone or wrote them down on paper.
If I was working on a php/mysql website and I click on Login which takes me to login.php and I get something like: PHP parse error : syntax error, unexpected T-STRING on line 130 in file /home/user/www/login.php I can then run more +130 /home/user/www/login.php which will start me on line 130 where the error is so I can look for what is wrong and then fix it.
Now for some examples of less.
If I was working on a php/mysql website and I was writing a foreach() loop on my php script and needed a little help from someone that has a copy of my script, I could do less -N some-script.php and tell him or her what lines I was having problems with.
Well that’s it for the Linux more and less commands. As always I hope this Linux tutorial on the Linux less and more commands has helped you understand more and less a bit more! Thank you for reading my Linux tutorials on Beginner Linux Tutorial, I hope you have a great day! Any questions of problems with more or less can be asked below in the comment section.

Linux chown Command Change Owner

The Linux chown command is used to change the owner and group of a file or directory. If you have a directory and you are not the owner and would like to be the owner of that directory, you can use the Linux chown command to change the owner to your username.
Some of you may get a lot of permission denied errors while trying to open files or folders, this may be caused by improper ownership or owner permissions. If it is a ownership problem, chown will fix your problem. If it is a permission problem, then you will want to look into chmod.
The usage of chown is chown [OPTIONS] [OWNER]:[GROUP] [FILE]. There are many options for chown, but I only use 2 of them on a regular basis. I use chown -R | --recursive and also chown --from=CURRENT_OWNER:CURRENT_GROUP. Basically chown -R is used on directories and all files in that directory. chown --from=CURRENT_OWNER:CURRENT_GROUP is used if you want to only change files that are currently owned by CURRENT_OWNER:CURRENT_GROUP.
For some examples of the Linux chown command. Say I have a desktop computer with Linux on it, and my username on the desktop computer is BrandonStimmel, and I buy a new laptop and install Linux on it, and this time I made my username Brandon. I also want to get rid of my desktop because it is slow and uses a lot of electricity. So I want to copy all of my files and folders from the desktop’s /home/BrandonStimmel to the laptop’s /home/Brandon. I simply use rsync, cp, or scp to copy the files and folders from the desktop computer to the laptop computer. Trouble is, I can only read files, I can’t write to them. I keep getting permission denied errors, and you don’t have permission to write to the file $FILE. So I login to the laptop as my user, then su to root, since root has permissions to read and write to the files/folders. Then I run chown -R --from=BrandonStimmel:users Brandon:users /home/Brandon/* Some may ask why I used chown --from= in this example. Well I have a ton of files in my home folder from my desktop and I may have some files that were meant to be owned by root, or some other user as backups. I didn’t want to change all of them to my new username unless I owned them before.
If you use the same example but don’t care who previously owned the files/folders, you can run chown -R Brandon:users /home/Brandon/* and you will change all files/folders in /home/Brandon to be owned by the username Brandon and the group users.
I hope this Linux tutorial on the Linux chown command has helped you fix your permission issues. If you have any questions please feel free to contact Beginner Linux Tutorial by leaving a comment or sending an email. Have a great day and remember to read more Linux tutorials! Knowledge is power, especially with Linux!

Fastest Linux Shell

There are many of you out there always looking for another way to tweak your Linux computer to make it even faster. Well this is just one of my tips that will help speed up your overall system slightly. Most of you out there are probably using bash as your Linux shell. This is fine, but there are other shells available that are faster, smaller, and use less system resources.
Everytime you login to your Linux system, open a terminal, execute a script, etc. you are opening up another Linux shell. Most of you Linux users are thinking it’s just a Linux shell, it doesn’t take up much resources, that’s true, but just think if you had 10 shells running. The system memory usage would increase a bit. Plus for those of you that don’t have faster computer hardware with tons of resources, we want to conserve as much RAM as possible.
So what can we do about all these Linux shells running eating up our system resources? We can install a lightweight shell and set it to be your default Linux shell. Let’s install dash which is a replacement of ash (Almquist Shell) which was a BSD-licensed replacement for the Bourne Shell that was used in low resource systems.
Depending on what Linux distro you are running, you may need to install dash slightly differently. First lets install dash.
  • Gentoo: emerge --sync && emerge dash
  • Debain: apt-get update && apt-get install dash
  • Fedora: yum install dash
Now that you have dash installed, we want to make dash your default Linux shell. To do this first we want to open a terminal. Type su, enter your root password, open your favorite text editor and edit /etc/passwd. Any username you want to use the dash shell, change /bin/bash to /bin/dash and save the file.
Now we want to change the symlink of /bin/sh to point to /bin/dash instead of /bin/bash. To do this we must first delete the current symlink /bin/sh. In your terminal, type rm -f /bin/sh now we need to create a new symlink to /bin/dash. To do this in your terminal type ln -s /bin/dash /bin/sh and now you are done. Logout and log back in and all of your terminals and shells will be using dash.
NOTE: dash is a very lightweight Linux shell and does not have many features that bash and some other Linux shells have. dash does not support tab complete, so you can’t type cd /us(TAB)sr(TAB)lin(TAB) and be taken to /usr/src/linux. dash does not support history either, so if you were just doing a bunch of long commands in a shell and didn’t want to retype them, just hit up a couple times and then hit enter, well you can’t with dash, but you will notice your scripts running faster, terminals opening faster, less ram being used, etc.
I hope this Linux speed tweak has helped you tweak your Linux computer to make it even more faster! For more Linux tutorials and speed tweaks continue reading through Beginner Linux Tutorial!