Useful tips and commands for absolute Linux beginners.
The Linux command line has many useful commands that are useful for managing files and installing software. I will cover a few in this post.
cp. This command is used to copy a file from one location to the other. For example:
cp myfile.txt Desktop/myfile.txt which will copy the file to the new location.
mv This command will move the file to the new location. Therefore this command:
mv myfile.txt Desktop/myfile.txt will move the file to the new location.
rm This is the command used to delete files on a UNIX or Linux system. The command:
rm myfile.txt will permanently delete the file myfile.txt. The -f parameter will force the deletion of a file. Use the -r parameter to allow recursive deletion of a directory. This command combines them:
rm -rf Documents.
ls List a directory. This is the Linux alternative to the DIR command for DOS. This will list a directory. Use this command to list all files:
ls -a and this command to list all files in a list view:
cat Nothing to do with cute cats, this command will display the contents of a file to the screen. For example:
head Reads the beginning of a file. Use the -n 10 parameter to only read 10 lines from the beginning of the file.
tail Reads the end of a file. Use the -n 10 parameter to only read 10 lines from the end of the file.
less Allows you to read a file like cat, but allows the user to scroll through the file. Just like this:
less mytextfile.txt and this is easy as pie.
man intro This command is used to show a manual page in the terminal. This one explains the workings of the Linux command line and some useful tips for beginners. You may get help on any command by typing
man ls for example.
sudo apt-get update
Updates the package repositories.
sudo apt-get upgrade
This will install any pending package updates for a Debian system.
To add a new user to your system use the adduser command. An example is shown below. This performs the whole process of creating a user in one go.
[email protected]:~$ sudo adduser joe Adding user `joe' ... Adding new group `joe' (1002) ... Adding new user `joe' (1002) with group `joe' ... Creating home directory `/home/joe' ... Copying files from `/etc/skel' ... Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Changing the user information for joe Enter the new value, or press ENTER for the default Full Name : Joe Smith Room Number : 101 Work Phone : 099 099 123 Home Phone : Other : Is the information correct? [Y/n] y
sudo userdel This command will remove a user from a Linux system. For example:
sudo userdel jim