How change path autostart in console

F

femtosekunda

Guest
My console start /home/kk
I wrote script bash
#!/bin/bash/
cd /C/Users/kk/Desktop

but nothing happens, Why?
 


Because you don't have a directory called /c/Users/kk/Desktop/ anywhere on your system.

Your console starts in /home/kk - this is standard on Linux.
If you want to start in the desktop directory in your home folder, you could edit your .bashrc file using a text editor and add the following line at the end:
Code:
cd ~/Desktop

Then every time you start a new terminal, you will end up in /home/kk/Desktop

But the path you gave looks more like the path to the desktop folder in a Windows partition/drive.
If you are trying to access the Desktop folder in a windows partition/drive then it is a completely different story:
- Paths in Linux and other unix-like OSes are nothing like Windows, so forget about all notion of C:/ D:/ E:/ etc.
- The root of the filesystem is / (or root). All devices and files are in various sub-directories off of root (/).
- Typically, all hardware devices, including drives and partitions are listed somewhere in /dev/.
- Hard-drives are typically given identifiers like sda, sdb, sdc etc. Where sda is the primary hard-drive.
- Partitions on each drive are typically assigned numbers.
So sda1 is the first/primary partition on the primary hard-drive.
Likewise, sdb1 would be the first/primary partition on a second hard drive (or it could be a USB thumb-drive).
sda4 would be the 4th partition on the primary drive. etc....

- Typically Windows is installed on the first/primary partition on the main hard-drive. So it is often /dev/sda1 - but it is not guaranteed to be the case. Either way, the way to determine the appropriate path to your Windows partition is to use the fdisk command:
Code:
fdisk -l

The output from fdisk will list all of the physical drives connected to the machine and the partitions and file-systems they contain. From the sizes and file-system types, you should be able to work out which one is your Windows partition.

Once you know the path to your windows drive, you then need to create a mount-point for the drive and then mount the drive at the mount-point.

In order to get your terminal to always start in your Desktop folder in your Windows partition, that would mean that your Windows drive/partition would always have to be mounted. So you would have to create an entry in fstab. That way - each time your machine is rebooted, your Windows partition always gets mounted at the same point.

However, this is REALLY inadvisable IMO. If your Windows partition is always mounted, then there is more of a chance that you might accidentally damage your Windows install (e.g. via an accident involving the rm command).

IMO, It is much safer to ONLY mount the Windows partition when you need to access it and to unmount it when you are finished with it! Anyway, if you decided to go the fstab route, then you could just add something to the end of your .bashrc command to cd into the appropriate directory.

So if the Windows partition was mounted at /media/c in fstab, then you could add:
cd /media/c/Users/kk/Desktop
to the end of your .bashrc file.

That way fstab will ensure that the drive is always mounted when you boot up. And every time you open a terminal, the entry at the end of .bashrc will cd you into your Windows Desktop directory. That achieves what I think you are asking in the title of your thread. But once again, I will maintain that this is a bad idea!

Personally, I'd recommend leaving your terminal starting in /home/kk/ and instead create a script to manually mount your windows partition, another script to manually unmount the windows partition and perhaps a bash alias to quickly cd into your Windows Desktop directory.

I can give you instructions on how to manually mount/unmount your windows partition and set up some aliases. OR if you REALLY want, I can give instructions on how to set up fstab to always mount your Windows partition. But yet again, I think this is a monumentally bad idea!

I hope this at least answers your question about why /C/Users/kk/Desktop doesn't work....
:)
 

Staff online

Members online


Latest posts

Top