Command Line Reference¶
author: | jozee, linea, seawolf, naitsirhc, genesis, hgt |
---|
Introduction to the commands¶
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 CD-ROM. You can use the command su to become system administrator.
Help and list available commands¶
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 --help
option.
Example using the cp command to copy files:
$ cp --help
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:
$ busybox --help
List the files in a directory¶
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:
$ ls
List all the files using the -al
option:
$ ls -al
List a directory:
$ ls /home/slitaz
Moving around directories¶
To browse to the files, you can use the cd command:
$ cd /usr/share/doc
Back to the parent directory:
$ cd ..
To go into the directory of the user (root = /root
):
$ cd
Or:
$ cd ~
Or:
$ cd $HOME
Copy files¶
The cp command copies files or folders.
The example copies the info.txt
file in the current directory into the Documents
directory:
$ cp info.txt Documents/
Copy a whole directory.
Here the command copies the Templates
directory into /home/hacker
:
$ cp -a Templates /home/hacker
Move (rename) files or directories¶
When source and target file are in the same file system and the target file does not exist, the mv command simply renames the source file:
$ mv file1 file2
It can also rename directories (provided the new directory doesn’t exist):
$ mv ~/Documents ~/Docs
Move files (and directories) to a new directory:
$ mv file1 file2 dir1 dir2 ~/Documents
When renaming is not possible, the mv command takes the contents of a file and copies it to a new file, then deletes the original file.
Create a new directory¶
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:
$ mkdir Projects
Creation of a directory named script-1.0
in the Projects
folder:
$ mkdir Projects/script-1.0
You can also create a directory tree with the -p
parents option:
$ mkdir -p one/two/three/four
Delete files or directories¶
The command rm lets you delete a file.
Let’s remove the file work.txt
which is in the current directory:
$ rm work.txt
The command rm has several options.
To delete a directory and its contents, we use the -rf
option.
Example:
$ rm -rf /home/hacker/Templates
Important
Be careful when using this option. It will delete everything without asking!
Note you can also use the -i
option to remove files or directories and their contents interactively:
$ rm -ir /home/hacker/Templates
View files¶
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
:
$ less -EM essential.txt
or:
$ more README
or:
$ cat /path/to/script.sh
Display a text or html file with the web browser Retawq:
$ retawq /usr/share/doc/index.html
Edit files¶
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):
$ nano Public/bookmarks.html
cat¶
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:
$ cat > packages.list << "EOF"
The text...
and more text
EOF
To append to the following text file, put two greater than signs (>>
) after cat, example:
$ cat >> packages.list << "EOF"
The text...
EOF
Talk on IRC¶
To discuss and transfer files via the many IRC servers available, SliTaz provides LostIRC.
The IRC client is simple, fast and lightweight, providing a pleasant, easy to handle GTK configuration menu.
One of the main IRC channels for slitaz is irc.freenode.net#slitaz
Download files¶
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:
$ wget http://www.slitaz.org/en/doc/
List the available partitions¶
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:
$ cat /proc/partitions
or:
# fdisk -l
Mount a partition, CD or USB drive¶
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
:
# mkdir -p /mnt/hda6
# mount -t ext3 /dev/hda6 /mnt/hda6
SliTaz functions in RAM, you can mount the same CD-ROM or remove it to mount another (/dev/cdrom
is a link to the first CD-ROM drive).
Note that a CD-ROM is a removable medium and should be mounted on /media
:
# mount -t iso9660 /dev/cdrom /media/cdrom
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
:
# mount -t vfat /dev/flash /media/flash
Turn off the system or restart¶
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:
# halt
To restart:
# reboot
Or:
# reboot -f