Professional Documents
Culture Documents
Basic Linux Commands
Basic Linux Commands
ls
cd /path/to/directory
pwd
cp source_file destination_file
mv old_name new_name
rm file_name
mkdir new_directory
rmdir directory_name
touch file_name
cat file_name
nano file_name
ps aux
top
These commands form the basis for navigating and manipulating files, directories, and
system processes in a Linux environment.
Creating a file in Unix can be done using several different commands, depending on
your needs. Here are a few common methods:
1. **Using the `touch` command**: This creates an empty file or updates the timestamp
of an existing file.
touch filename
2. **Using the `echo` command**: This can create a file with some initial content.
3. **Using the `cat` command**: This allows you to type content into a file.
After entering the above command, type your content and then press `Ctrl+D` to
save and exit.
4. **Using the `nano` command**: This opens the nano text editor to create and edit a
file.
nano filename
After entering your content, press `Ctrl+O` to write out (save) the file, then `Ctrl+X`
to exit nano.
5. **Using the `vi` or `vim` command**: This opens the vi or vim text editor to create
and edit a file.
vi filename
Once in vi, press `i` to enter insert mode, type your content, then press `Esc` to exit
insert mode. Type `:wq` and press Enter to write (save) the file and quit vi.
6. **Using the `>` operator**: This creates an empty file.
> filename
Each method has its own advantages, whether you need an empty file, want to add
some initial content, or prefer to edit the file interactively.
script
read NAME
# Loop script
for i in {1..5}; do
done
read num1
read num2
echo "Choose operation: + - * /"
read operation
case $operation in
+) result=$((num1 + num2)) ;;
-) result=$((num1 - num2)) ;;
*) result=$((num1 * num2)) ;;
/) result=$((num1 / num2)) ;;
esac
chmod +x script.sh
./script.sh