More Linux commands:

-------

List the contents of a directory one page at a time using the Spacebar (similar to dir/p in DOS):
To advance one line at a time, press Enter

ls -a |more

(Ctrl C will quit the list and go back to the shell prompt).

---

A short way to tell the computer that you're referring to the current folder is to type a single period.

So if you're in your home folder and you type the following, it'll copy the file called blitter from
the Amiga folder and it'll put it into your home folder:

cp /'home/username/Desktop/My files/Amiga/blitter' .

---

Copying the files named Max and Carter to a folder called Network23 and the Network23 folder is in
the My files folder (under Desktop), type:

cp Max Carter /'home/username/Desktop/My files/Network23'

---

To copy a file named BaseStar.jpg from your current directory into a sub-folder called Cylons

cp BaseStar.jpg Cylons

---

To copy everything in your current folder into the /Desktop/My Files/jpg folder, type:

cp -R * /'home/username/Desktop/My files/jpg'

Note: -R means Recursive (or copy sub directories along with it).

---

To copy the contents of pics1 and pics2 to a folder called photos that's located inside your My files folder

cp -avr pics{1,2} /'home/username/Desktop/My files'

The above copies folders within folders to the My files folder. So if there are any subdirectories inside
pics1 or pics2, those subfolders and their files will be copied over as well.

---

To make a copy of a file called recognizer1 and call the copy recognizer2

cp recognizer1 recognizer2

---

To get a listing of the various switches available for the cp command, type:

cp --help

---

Folders and files with spaces in their names can be surrounded by either double or single quotes.

---

Typing cd by itself takes you to your home folder.

---

Folders with names starting with a . are usually very important system folders and many of them are read on startup.

So if you see a period in front of a folder name, it's probably a good idea not to mess with that folder.

---

To noodle around in the file structure, starting at your home folder, put a tilde at the front of the path. E.g.)

ls ~/Downloads

---

To list all files in a folder (including the hidden ones):

ls -a

---

To sort files in the listing based on the time that they were modified and show as a list with date shown for each file and folder:

ls -lt

---

To rename a file called egon1 to egonspengler type:

mv egon1 egonspengler

---

To see what's in a text file without using an editor:

less file.txt

(Press the space bar to continue a page at a time).

Type q to exit the reader.

---

To search for the word slim-bot in a file called phat.txt, type:

less phat.txt

Once the file is open, type:

/slim-bot

---

Type stuff into a new text file called movie-list.txt without a word processor or text editor:

cat > movie-list.txt

Now type in the movies that you'd like in your document:

Blade Runner
Star Trek II
TRON

Pressing Control D will exit text entry mode and auto-save the text file.

If you decided that you wanted to add another movie to the list, type:

cat >> movie-list.txt

The Dark Crystal

Press CTRL D like before when done.

To show what's in the text file, use either cat or less. E.g.)

cat movie-list.txt

less movie-list.txt

---

To sort the list of movies alphabetically and send that to a new text file called movies_A-Z.txt

sort < movie-list.txt > movies_A-Z.txt

---

* matches any character and any number of characters.

? matches only one character.

To list only the files starting with sci, type

ls sci*

To list just the files that end with iction, type

ls *iction

And to list only three-letter files that end with the letters ad

ls ?ad

---

If you have the access rights, you can change a file's permissions.

To make it so that you can't overwrite the file called Design.txt

chmod u-w Design.txt
(a means all, g means group, and u means user)

And to give both execute and write permissions to everyone for the Design.txt file

chmod a+wx Design.txt

---

To get a list of files by type:

file *

---

Search the entire drive for a file names Alpha:

sudo find / -type f -iname "Alpha"

---

Search entire drive for directory named Omega:

sudo find / -type d -iname "Omega"

(f stands for file and d stands for directory). Press Crtl C to cancel search.

---

If Linux won't let you eject a USB stick or USB drive, there might be programs still claiming that drive.

To find out what's keeping the drive from being software ejected,
- Type lsblk
- Take a look at the connected devices. Typically, a USB drive will have a name like sdc1
- If yours shows up under the path /media/username/03C9-5FA0, you'd type
fuser -v /media/username/03C9-5FA0
- It'll show you which program or process is holding up the USB drive.
Closing that program or killing that process should make it possible to eject the USB drive.

---

Environment variables (shown in uppercase letters):

These are things that can be changed that affect the entire environment or system.
Here are some examples:

USER <-- Your usename can be whatever you want it to be.

HOME <-- The location of your home folder. You could change this if you wanted to.

HOST <-- The name of the computer you're using. That could be changed too.

ARCH <-- If you swapped out your CPU, then you'd be changing this environment variable.

To see what your environment variables are currently, type:

printenv | less

(Press q to exit the listing)

---

Shell variables (shown in lower-case):

You can customize the particular command line shell without affecting any other shell windows.

cwd <-- This is your working directory. Again, changeable.

home <-- If you choose another home folder location, it will only apply to this shell instance.

prompt <-- You could make your prompt read, "By your command:" for just this shell, if you wanted to.

Tip: In general, it's best not to mess with environment and shell variables unless you need to.

-------

Note: You probably won't need a lot of the above commands, unless you're using a command-line-only version of
Linux like the one that Micro$oft reportedly uses to maintain their web servers.

Avoid using the following characters in your file names (some of them have other meanings to Linux and characters
like the following can make file transfers to other operating systems difficult or impossible):

/ * & % | ?

-------

How to change your user name and password in Linux Lite v 5.8:

- Menu -> Settings > Lite User Manager
Note: It's just [User Manager] in regular Linux.

- Click [New User]
- Create a new user called temp
- Give it the same password as the existing user account

- On the right side of the User Manager, scroll down and check sudo.
- Click [Apply] and [Quit]
- Menu -> Settings -> Lite User Manager

Make sure that sudo really is checked.

If it is,
- Click Menu -> Turn Off Computer
- Choose [Log Out]
- Now log in using the temp user account.

- Open a shell and type
sudo su

- Type your root password and press Enter.

Note: newaccount should be the name of the new account that you're creating.
oldaccount should be the name of the old account that you're transferring settings from.
NewAccountLabel is the tag you want to label the new account with. It can be whatever you like.

In the terminal shell, type the following:

killall - u newaccount oldaccount
id oldaccount
usermod -l newaccount oldaccount
groupmod -n /home/newaccount -m newaccount
usermod -c "New Account Label" newaccount
id newaccount

You should see a bunch of categories with the new account name in brackets after them,
showing that the new account is now a member of the groups that the old account belongs to.

Reboot and log in using the new account.

Delete the temp account that you made:
- [Menu] -> [Settings] -> [Lite User Manager]
- Set the top right drop-down to [temp]
- Click [Remove selected user]

To change the password for the new account, open a command line shell and type:

sudo passwd

Or go to the User Manager and click [Change password]

Note: You might have to reboot before you'll be able to remove the other accounts using the User Manager.
Also, you can't (and shouldn't) delete the account named root.

---





Linux_quick-guide.pdf

Linux_quick-guide.doc



[Blitter.Com]