slitaz-doc-wiki-data view pages/en/handbook/commands.txt @ rev 7

Add pages/en folder.
author Christopher Rogers <slaxemulator@gmail.com>
date Sat Feb 26 12:17:18 2011 +0000 (2011-02-26)
parents
children 63abeb36532d
line source
1 ====== Command Line Reference ======
3 ===== Introduction to the commands =====
5 This document is intended as a quick reference for using commands on SliTaz via a Linux terminal or a graphical terminal (xterm). There are many GNU/Linux commands for file handling, system maintenance or network management. You can also browse the web, chat on IRC, download files, edit scripts or even play games in text mode. Note it is necessary to operate as root to assemble the hard drive or cdrom. You can use the command //su// to become system administrator.
7 ===== Help and list available commands =====
9 Most GNU/Linux system commands have an option for providing information on their use. For support on the use of a command, it is necessary to type the command followed by the <nowiki>--help </nowiki> option. Example using the cp command to copy files:
11 <code> $ cp --help </code>
13 To list all the commands available on the system, you can simply press the Tab button on the left of the keyboard twice. For commands provided by the Busybox utility you can type
14 <code> busybox --help. </code>
16 ===== List the files in a directory =====
18 To list the files and folders contained in a directory, you can use the ls command. For all options remember to use the --help flag. To simply list the files in the current directory:
20 <code> $ ls </code>
22 List all the files using the -al option:
24 <code> $ ls -al </code>
26 List a directory:
28 <code> $ ls /home/slitaz </code>
30 ===== Moving around directories =====
32 To browse to the files, you can use the //cd// command:
34 <code>
35 $ cd /usr/share/doc
36 Back to the parent directory:
37 $ cd ..
38 </code>
40 To go into the directory of the user (//root = /root//):
42 <code>
43 $ cd
44 Or :
45 $ cd ~
46 Or :
47 $ cd $HOME
48 </code>
50 ===== Copy files =====
52 The //cp// command copies files or folders. The example copies the info.txt file in the current directory into the Documents directory:
54 <code> $ cp info.txt Documents/ </code>
56 Copy a whole directory. Here the command copies the Templates directory into /home/hacker:
58 <code> $ cp -a Templates /home/hacker </code>
60 ===== Move (rename) files or directories =====
62 The mv command takes the contents of a file and copies it to a new file, then deletes the original file:
64 <code> $ mv file1 file2 </code>
66 It can also rename directories (provided the new directory doesn't exist):
68 <code> $ mv ~/Documents ~/Docs </code>
70 Move files (and directories) to a new directory:
72 <code> $ mv file1 file2 dir1 dir2 ~/Documents </code>
74 ===== Create a new file =====
76 The touch command can create a new empty file:
78 <code> $ touch newfile </code>
80 ===== Create a new directory =====
82 This command will create a new directory. The following command creates a directory called Projects. It will be created in the directory ///home// of the current user or in the directory which one is in. Note you can display your current working directory with the //pwd// command:
84 <code> $ mkdir Projects </code>
86 Creation of a directory named script-1.0 in the Projects folder:
88 <code> $ mkdir Projects/script-1.0 </code>
90 You can also create a directory tree with the -p parents option:
92 <code> $ mkdir -p one/two/three/four </code>
94 ===== Delete files or directories =====
96 The command //rm// lets you delete a file. Let's remove the file work.txt which is in the current directory:
98 <code> $ rm work.txt </code>
100 The command //rm// has several options. To delete a directory and its contents, we use the //-rf// option. Example:
102 <code> $ rm -rf /home/hacker/Templates </code>
104 Note you can also use the //-i// option to remove files or directories and their contents interactively:
106 <code> $ rm -ir /home/hacker/Templates </code>
108 ===== View files =====
110 To read the contents of a file or script, you can use the less, more or cat commands, or the web browser Retawq. Examples with a README file, essential.txt, and script.sh:
112 <code>
113 $ less -EM essential.txt
114 or :
115 $ more README
116 or :
117 $ cat /path/to/script.sh
118 </code>
120 Display a text or html file with the web browser Retawq:
122 <code> $ retawq /usr/share/doc/index.html </code>
124 ===== Edit files =====
126 Editing text files, scripts, configuration files, etc, can be done easily using the text editor GNU Nano in a console or graphical terminal. Example with a file bookmarks.html (<Ctrl+X> to quit and save):
128 <code> $ nano Public/bookmarks.html </code>
130 ===== Cat =====
132 You can use the //cat// command to create various text files. EOF signifies End Of File, this is where the file ends. Example with a file packages.list, this removes the current contents of the file and lets you add some new text:
134 <code>
135 $ cat > packages.list << "EOF"
136 The text...
137 and more text
139 EOF
140 </code>
142 To append to the following text file, put two greater than signs (>>) after cat, example:
144 <code>
145 $ cat >> packages.list << "EOF"
146 The text...
148 EOF
149 </code>
151 ===== Navigate the web =====
153 Surf the web quickly and simply with the 'retawq' text-mode web browser. Note that you can also use the local browser. You can then navigate easily with the arrows on your keyboard - links are colored blue and can be followed by pressing <ENTER>:
155 <code>
156 $ retawq http://www.slitaz.org/en
157 or :
158 $ retawq http://localhost/
159 </code>
161 ===== Talk on IRC =====
163 To discuss and transfer files via the many IRC servers available, SliTaz provides Rhapsody. The IRC client is simple, fast and lightweight, providing a pleasant, easy to handle ncurses configuration menu. To start the application from a terminal connecting to server (//irc.toile-libre.org//) and joining //#slitaz//:
165 <code>
166 $ rhapsody
167 /connect irc.freenode.net
168 /join #slitaz
169 </code>
171 ===== Download files =====
173 To download various file formats on the internet, you have the //wget// command. To grab a simple html page, the contents of a folder or an entire website:
175 <code> $ wget http://www.slitaz.org/en/doc/handbook/ </code>
177 ===== List the available partitions =====
179 To list the partitions on an internal or external hard drive, you can use cat to display the contents of ///proc/partitions// or use the //fdisk// utility with the -l option meaning list. You can then mount the individual partition(s) that you want to use:
181 <code>
182 $ cat /proc/partitions
183 or :
184 # fdisk -l
185 </code>
187 ===== Mount a partition, CD or USB drive =====
189 To mount a local partition in the SliTaz filesystem, we recommend you use the ///mnt// directory. Example creating the necessary directory and mounting the hda6 partition of the first local hard drive on ///mnt/hda6//:
191 <code>
192 # mkdir -p /mnt/hda6
193 # mount -t ext3 /dev/hda6 /mnt/hda6
194 </code>
196 SliTaz functions in RAM, you can mount the same cdrom or remove it to mount another (/dev/cdrom is a link to the first cdrom drive). Note that a cdrom is a removable medium and should be mounted on ///media//:
198 <code> # mount -t iso9660 /dev/cdrom /media/cdrom </code>
200 To mount a USB or flash drive you must specify the proper filesystem. Normally a USB key is formatted in FAT32 which can be read from GNU/Linux and Windows operating systems. On a GNU/Linux system is it generally recognized as the sda1 device - we now prepare a link sda1 on flash to facilitate the task. Note it is also a removable medium and should be mounted on ///media//:
202 <code> # mount -t vfat /dev/flash /media/flash </code>
204 ===== Turn off the system or restart =====
206 To stop or restart SliTaz, you can use the halt or reboot commands or the <Ctrl+Alt+Delete> key combination which enables a system reboot. In case of any problems you can use the -f option signifing forced:
208 <code>
209 # halt
210 To restart :
211 # reboot
212 Or :
213 # reboot -f
214 </code>