Previous Page : The Ultimate Power Tool ; Terminals, xterms And Shells; First Steps On the Shell; Using The Shell I
Using the command-line editor (shell) II : the very first shell commands to experiment
Table of content :
- Introduction
- Knowing 'where you are'
- Creating an empty file
- To add a line at the end of a file without removing its content
- To read the content of a file
- To replace the content of an existing file with another content or to create a file with a specific content
- To read the content of a file spreading across several pages
- To change the name of a file or a directory
- To create a new copy of a file
- To see what's inside a directory
- To go elsewhere
- To clean up
- To create or remove directories
- To put a file somewhere else
- To look for some text in a file
- To know what is happening right now
- To have a look at what you've done
- To become administrator and quickly go back under your standard identity
- Other resources
Section index - Knowledge Base index
Introduction
If you're a beginner, have fun playing in a console with these first commands.
To open a console :
- Press simultaneously Alt+Ctrl+Fn keys (n being between 1 and 6) : you come back to your classical graphical environment with Alt-F7
- Or click on K Menu -> System -> Terminals and choose, for instance, Konsole.
Knowing 'where you are'
- The pwd command displays the name of the working directory (sometimes called current directory).
To remember more easily : 'pwd' is the acronym of print working directory.
Creating an empty file
- Use the command touch file_name.
If file_name is an existing file, only its date and hour will be changed, its content will not be modified.
To add a line at the end of a file without removing its content
- A combination between the 'echo' command and the redirection operator '>>' (be careful not to confuse with '>' described below) :
echo "blah blah blah" >> file_name
.
To read the content of a file
- The command cat file_name displays the content of a text file.
To replace the content of an existing file with another content or to create a file with a specific content
- Similar to the last-but-one command, but using this time the redirection operator '>' :
echo "blah blah blah" > file_name
To read the content of a file spreading across several pages
- The command less file_name displays the content of a file and allows moving into it.
To change the name of a file or a directory
- The command mv name1 name2 renames the file or directory name1 into name2.
To create a new copy of a file
- The command cp file1 file2 creates file2 by copying the content of file1 into it.
To see what's inside a directory
- The command ls -l lists the content of the working directory.
- The command ls -la lists the content of the working directory and includes hidden files.
- The command ls -l dir lists the content of the 'dir' directory.
To go elsewhere
- The command cd directory changes the working directory.
To clean up
- The command rm file removes a file.
To create or remove directories
- The command mkdir directory creates a directory.
- The command rmdir directory removes an empty directory.
To put a file somewhere else
- The command mv file directory moves the file 'file' to the directory 'directory'.
To look for some text in a file
- The command grep text_to_look_for file_name looks for a text in a file.
- The command grep -i chaine_à_chercher nom_de_fichier does the same thing but do not care about uppercase and lowercase letters.
To know what is happening right now
- The command top lists programs using the most your CPU (they will be up in the display). Use 'q' to quit.
- The command ps ux lists all active programs belonging to the current user.
- The command ps aux lists all active programs in the system.
To have a look at what you've done
- You can recall and see the previous commands you've typed using up and down arrow keys on your keyboard.
- The command history displays a list of the last commands used.
To become administrator and quickly go back under your standard identity
- The command su - switch you to the administrator mode, i.e. you become 'root' (be careful : don't stay under root to experiment all these commands, a mistake can be made very quickly!).
- The command exit bring you back to your previous identity.
Other resources
- How to copy files and folders with the 'cp' command
- How to move files and folders with the 'mv' command
- Searching Text Files With 'grep'
- Some tips for the shell history
- How to customize 'ls' output
Next page : Auto-Completion ; Commandline History ; Commandline Editing ; Available Shell Shortcuts
Author : ptyxs (march 2006)
Utiliser l'éditeur de commandes (shell) II : les toutes premières commandes du shell à expérimenter
Version 1.13 last modified by ptyxs on 12/03/2006 at 18:49
Version 1.13 last modified by ptyxs on 12/03/2006 at 18:49
Document data
- Lost account?
- Join the community, be part of the Club: it's free!
- Get the PWP Download Subscription!