Advertisement

   

Cyberfreek on Twitter  

   

CyberFreek Follows:  

   

For those new or even those advanced users, sometimes we need a little kick start to remember the commands for Linux. This is meant as a starter page for you:

 

Remember, Links / Files are for Linux only.

 

Abstract

 

Fundamental Linux/Unix commands for the Linux/Unix command line learner. If you are experienced with Linux/Unix: you have probably mastered these commands. If not: you are in the right place.

 

            Note: Some of the examples below presume files and paths that might not match your particular system and tool installation.


  

 

Where to Acquire

 

These tools are installed natively in most Unix/Linux distributions, as well as OS X.

 

Examples/Use Case


bash-basics

Tab-completion:

 

Folks who are new to the Unix/Linux command line often attempt to type everything by hand. This may work well if you type quickly and accurately. Most of us are much better off using tab completion.

 

 

Note that Windows PowerShell also supports tab completion, but it handles ambiguity differently. See the PowerShell cheat sheet for more information.

 

 

Type the following, and then press the <TAB> key:

 

$ cat /etc/pas

 

Then press <TAB>.

 

 

Note that it autocompletes to /etc/passwd.

 

 

Now try tabbing with ambiguity:

 

$ cd ~/Do

 

Then press <TAB><TAB>.

 

 

Note that it offers two choices: Documents/ Downloads/.

 

 

Now add a "w" and press <TAB>:

 

$ cd ~/Dow

 

Press <TAB>. It autocompletes to ~/Downloads/.

 

cat

 Display a file:

 

$ cat example.txt

 

Concatenate (cat) FileA.txt and FileB.txt, create FileC.txt:

 

$ cat FileA.txt FileB.txt > FileC.txt

cd

 

Change Directory (cd) to the /tmp directory:

 

$ cd /tmp

 

Change to the home directory. The following commands are equivalent for the "student" user: "~" means home directory (for example: /home/student):

 

$ cd
$ cd ~
$ cd /home/student

 

Change to the parent directory. For example: if you are in /tmp/subdirectory/, this will change your working directory to /tmp/:

 

$ cd ..

echo

 

Print (echo) the string "Cylon":

 

$ echo Cylon

 

Create or overwrite the file example.txt, containing the string "Cylon":

 

$ echo Cylon > example.txt

 

Append the string "Cylon" to the file example.txt:

 

$ echo Cylon >> example.txt

ls

 

List the files in the current directory (equivalent to the cmd.exe "dir" command):

 

$ ls

 

List the files in the current directory, long output (-l), all files including "hidden" files that begin with a "." (-a):

 

$ ls -la

 

List the files in the current directory, long output (-l), all files (-a), sort by time (-t):

 

$ ls -lat

 

List the files in the current directory, long output (-l), all files (-a), reverse (-r) sort by time (-t):

 

$ ls -lart

networking

 

Show network interface configuration:

 

$ ifconfig

 

Show network interface configuration using "ip":

 

$ ip a

 

Restart networking:

 

$ sudo /etc/init.d/networking restart

passwd

 

Change your password:

 

$ passwd

ping

 

ping a host forever (until CTRL-C is pressed), see if it is up (and unfiltered):

 

$ ping 10.5.11.25

 

ping a host 3 times, see if it is up (and unfiltered):

 

$ ping -c3 10.5.11.25

pwd

 

Print Working Directory (pwd), show the current directory:

 

$ pwd

sudo

 

Run a command as root:

 

$ sudo command

 

Open a root bash shell:

 

$ sudo bash

Additional Info

 

A printable PDF version of this cheat sheet is available here:
Original Version Location Link LinuxCLI101
Local Version Link: LinuxCLI101-v1

 

Cheat Sheet Version

Version 1.0

 

This document was shared from the original location.

See Original Version Location Link above.

   

Twitter for Cyberfreek

   
© Cyberfreek.com 1997-2024